Saturday, 31 August 2013

MySQL group by affecting other group

MySQL group by affecting other group

I've got a SUM(value) which calculates the votes for each idea, but this
gets affected by the amount of tags each idea can have.
For example,
SELECT
id,
title,
description,
COALESCE(SUM(case when value > 0 then value end),0) votes_up,
COALESCE(SUM(case when value < 0 then value end),0) votes_down,
GROUP_CONCAT(DISTINCT tags.name) AS 'tags',
FROM ideas
LEFT JOIN votes ON ideas.id = votes.idea_id
LEFT JOIN tags_rel ON ideas.id = tags_rel.idea_id
LEFT JOIN tags ON tags_rel.tag_id = tags.id
GROUP BY ideas.id
So if there are more than one tags.name, then the SUM() get multiplied by
the number of tags.name
How can I fix this?

How can I justify Tumblr blog posts horizontally?

How can I justify Tumblr blog posts horizontally?

I've tried using the recommended methods I've seen used on here for
justifying divs inside of divs, but none of the methods have worked on
Tumblr for blog posts. Any other suggestions for justifying posts
horizontally?

Trackment protection code

Trackment protection code

I have signed up Trackment, added my website. The given code for my
website is like;
<script src="http://trackment.com/?p=**code**"></script>
In their description, I need to add on my page, just after body tag. The
problem is that my designer havent add the body tag in the page, since its
a flash website.
I have added their code after my html tag, it works fine, however I
suspect if its working 100% correctly.
My question is, is it must to add the javascript code in between body tags
or its just a suggestion ? Note: javascript and jquery are included in my
web page.

Check string for # symbol and the immediately following characters, then colour that string

Check string for # symbol and the immediately following characters, then
colour that string

How can I check a string for a hash tag, and its connected following
characters?
Example: This is my sample string #example of what I mean.
I want to extract this: #example
Then I want to change the text colour of that found string

Perl Config:Simple error

Perl Config:Simple error

tried to use Perl Config:Simple to load a properties file, one version
works, but another doesn't.
error message is : Use of uninitialized value in print
Do you know why ?
#doesn't work
my %Config;
Config::Simple->import_from('properties.txt', \%Config);
print $Config{"array_cache_size"};
#work
my $cfg = new Config::Simple('properties.txt');
my $array_cache_size = $cfg->param('array_cache_size');
print "$array_cache_size\n";

UniversalImageLoader Does not load images from ContentProvider

UniversalImageLoader Does not load images from ContentProvider

my problem is this: I have a ListView in which i want to show song data. I
actually get the data from MediaStore. In the ListView items, i have an
ImageView in which i want to set the album art. I tried to use
UniversalImageLoader :
https://github.com/nostra13/Android-Universal-Image-Loader But images are
not loaded, i see only the "show-on-fail" image. on UniversalImageLoader's
page there is a section where an image path like :
"content://media/external/audio/albumart/243" is allowed.
This is my list adapter java class:
public class SongsAdapter extends BaseAdapter implements Filterable
{
public Context _c;
public ArrayList<Song> _data;
public ArrayList<Song> _originalData;
public SongFilter songFilter;
public ImageLoader imageLoader;
ImageLoaderConfiguration config;
public DisplayImageOptions options;
public ImageLoadingListener animateFirstListener;
public SongsAdapter(ArrayList<Song> _data, Context _c)
{
this._c = _c;
this._data = _data;
this._originalData = _data;
config = new ImageLoaderConfiguration.Builder(this._c)
.imageDownloader(new BaseImageDownloader(this._c))
.imageDecoder(new BaseImageDecoder(true))
.build();
options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.song_art_w)
.showImageOnFail(R.drawable.song_art)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.ARGB_8888)
.build();
imageLoader = ImageLoader.getInstance();
imageLoader.init(config);
animateFirstListener = new AnimateFirstDisplayListener();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if(convertView == null)
convertView =
((LayoutInflater)_c.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.list_item_song,
null);
Song s = _data.get(position);
ImageView songArt =
(ImageView)convertView.findViewById(R.id.song_art);
TextView songTitle =
(TextView)convertView.findViewById(R.id.song_title);
TextView songArtist =
(TextView)convertView.findViewById(R.id.song_artist);
TextView songAlbum =
(TextView)convertView.findViewById(R.id.song_album);
imageLoader.displayImage(BitmapUtils.getString(s.album_id),
songArt, options, animateFirstListener);
songTitle.setText(s.title.toUpperCase());
songTitle.setTypeface(Configuration.TEXT_BLACK);
songTitle.setSingleLine(true);
songArtist.setText(s.artist);
songArtist.setTypeface(Configuration.TEXT_REGULAR);
songArtist.setSingleLine(true);
songAlbum.setText(s.album);
songAlbum.setTypeface(Configuration.TEXT_REGULAR);
songAlbum.setSingleLine(true);
return convertView;
}
@Override
public int getCount()
{
return _data.size();
}
@Override
public Object getItem(int position)
{
return _data.get(position);
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public Filter getFilter()
{
if (songFilter == null)
songFilter = new SongFilter();
return songFilter;
}
private class SongFilter extends Filter
{
@Override
protected FilterResults performFiltering(CharSequence constraint)
{
String filterString = constraint.toString().toLowerCase();
FilterResults results = new FilterResults();
final ArrayList<Song> list = _originalData;
int count = list.size();
final ArrayList<Song> nlist = new ArrayList<Song>(count);
Song s;
for (int i = 0; i < count; i++)
{
s = list.get(i);
if(s.title.toLowerCase().contains(filterString))
{
nlist.add(s);
}
}
results.values = nlist;
results.count = nlist.size();
return results;
}
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint,
FilterResults results)
{
_data = (ArrayList<Song>)results.values;
notifyDataSetChanged();
}
}
private static class AnimateFirstDisplayListener extends
SimpleImageLoadingListener
{
static final List<String> displayedImages =
Collections.synchronizedList(new LinkedList<String>());
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap
loadedImage)
{
if (loadedImage != null)
{
ImageView imageView = (ImageView) view;
boolean firstDisplay = !displayedImages.contains(imageUri);
if(firstDisplay)
{
FadeInBitmapDisplayer.animate(imageView, 500);
displayedImages.add(imageUri);
}
}
}
}
}
Next, this is my xml layout for the single listView item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@drawable/icon_selector_gray"
android:clickable="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/song_art"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:gravity="center"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name">
</ImageView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp">
<TextView
android:id="@+id/song_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="left|center_vertical"
android:background="@android:color/transparent"
android:padding="0dp"
android:textSize="16dp"
android:textColor="#ff2a2a2a">
</TextView>
<TextView
android:id="@+id/song_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="left|center_vertical"
android:background="@android:color/transparent"
android:padding="0dp"
android:textSize="12dp"
android:textColor="#ff2a2a2a">
</TextView>
<TextView
android:id="@+id/song_album"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="left|center_vertical"
android:background="@android:color/transparent"
android:padding="0dp"
android:textSize="12dp"
android:textColor="#ff2a2a2a">
</TextView>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Finally, my app does not crash, but i got these exceptions (i would paste
one here, but for each song image art to load i got one exception same as
this)
No entry for content://media/external/audio/albumart/243
java.io.FileNotFoundException: No entry for
content://media/external/audio/albumart/243
at
android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
at
android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:612)
at
android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:607)
at
android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:536)
at android.content.ContentResolver.openInputStream(ContentResolver.java:371)
at
com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromContent(BaseImageDownloader.java:157)
at
com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:80)
at
com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:81)
at
com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:68)
at
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:305)
at
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:260)
at
com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:129)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
The strange thing is that 1 hour ago my imageLoader were working fine... i
think i have moved/removed some code, because i can't recognize the error
anymore. Did someone has implemented this, or know where the problem is?
thanks in advance.

can we made dialor(Example as in telephone) in jquery mobile+phonegap

can we made dialor(Example as in telephone) in jquery mobile+phonegap

can we made dialor(Example as in telephone) in jquery mobile.Please check
following images.I do lot of RND but not found much.
please check two pic's

Friday, 30 August 2013

Where's the documentation on 'use' and 'next'?

Where's the documentation on 'use' and 'next'?

I'm looking at the connect documentation, and there doesn't appear to be
any documentation on the .use method or anything that describes what
next() does (the secret 3rd parameter to use). Am I blind, or where can I
find this info?

Thursday, 29 August 2013

Pom.xml is not able to send email?

Pom.xml is not able to send email?

I have added this in my pom.xml . I am on windows7 , I am using
java+testng to write automation scripts. Do I need postfix smtp server to
send emails, thats why below code is not running for me, because same code
is running on ubuntu machine, which has postfix installed.
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>maven-postman-plugin</artifactId>
<executions>
<execution>
<id>send a mail</id>
<phase>test</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>false</inherited>
<configuration>
<from>test123@test.com</from>
<subject> Test Results</subject>
<failonerror>true</failonerror>
<mailhost></mailhost>
<receivers>
<receiver>paul.lev007@gmail.com</receiver>
</receivers>
<htmlMessageFile>target/surefire-reports/emailable-report.html</htmlMessageFile>
</configuration>
</execution>
</plugin>

Disk usage of Puppet reports

Disk usage of Puppet reports

We are running puppet-dashboard on the puppetmaster which processes all
the reports and puts them in a MySQL table. Every month about 5GB of
reports are generated however in /var/lib/puppet/reports.
What is the best way to control disk usage for Puppet reports?
Daily prune all reports older than 30 days with a cronjob.
Using logrotate on older report files (.yaml), if possible.
I am sure there are many people that have Puppet logging many gigabytes
every month. It seems too expensive to keep storing this data.

Wednesday, 28 August 2013

Adding a message box to a button icon

Adding a message box to a button icon

I am trying to add a message box when the user clicks on a certain button.
This is the code that I have:
{
text: 'Button Icon',
id: 'buttonIcon',
cls: 'x-btn-text-icon',
launch: function() {
Ext.MessageBox.show({
title: "",
msg: "Message Text",
icon: Ext.MessageBox.WARNING,
buttons: Ext.MessageBox.OKCANCEL,
fn: function(buttonIcon) {
if (buttonIcon === "ok") {
alert("Done!")
}
}
});
}
Right mow, when you click on the button icon nothing happens at all and I
need it to display the message that I have entered. Please Help.

PIL: Convert Bytearray to Image

PIL: Convert Bytearray to Image

I am trying to verify a bytearray with Image.open and Image.verify()
without writing it to disk first and then open it with im = Image.open().
I looked at the .readfrombuffer() and .readfromstring() method, but there
I need the size of the image (which I could only get when converting the
bytestream to an image).
My Read-Function looks like this:
def readimage(path):
bytes = bytearray()
count = os.stat(path).st_size / 2
with open(path, "rb") as f:
print "file opened"
bytes = array('h')
bytes.fromfile(f, count)
return bytes
Then as a basic test I try to convert the bytearray to an image:
bytes = readimage(path+extension)
im = Image.open(StringIO(bytes))
im.save(savepath)
If someone knows what I am doing wrong or if there is a more elegant way
to convert those bytes into an image that'd really help me.
P.S.: I thought I need the bytearray because I do manipulations on the
bytes (glitch them images). This did work, but I wanted to do it without
writing it to disk and then opening the imagefile from the disk again to
check if it is broken or not.
Edit: All it gives me is a IOError: cannot identify image file

how to write testcases for android RESTful webservices

how to write testcases for android RESTful webservices

how to write testcases for android RESTful webservices. I didnt found any
sample test case for android. If you found any link or post on android
RESTful webservices plz add. I have attached sample code down.
Main.java
public class Main extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.my_button).setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
Button b = (Button)findViewById(R.id.my_button);
b.setClickable(false);
new LongRunningGetIO().execute();
}
private class LongRunningGetIO extends AsyncTask <Void, Void, String> {
protected String getASCIIContentFromEntity(HttpEntity entity)
throws IllegalStateException, IOException {
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
int n = 1;
while (n>0) {
byte[] b = new byte[4096];
n = in.read(b);
if (n>0) out.append(new String(b, 0, n));
}
return out.toString();
}
@Override
protected String doInBackground(Void... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new
HttpGet("http://www.hindu.com/rss/23hdline.xml");
String text = null;
try {
HttpResponse response = httpClient.execute(httpGet,
localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
} catch (Exception e) {
return e.getLocalizedMessage();
}
return text;
}
protected void onPostExecute(String results) {
if (results!=null) {
EditText et = (EditText)findViewById(R.id.my_edit);
et.setText(results);
}
Button b = (Button)findViewById(R.id.my_button);
b.setClickable(true);
}
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Http GET Demo"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="GET"
android:id="@+id/my_button"/>
<EditText
android:layout_margin="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minLines="15"
android:maxLines="15"
android:textSize="12sp"
android:editable="false"
android:id="@+id/my_edit"/>
</LinearLayout>

how to get the date difference in days, minutes, seconds in PHP [duplicate]

how to get the date difference in days, minutes, seconds in PHP [duplicate]

This question already has an answer here:
How to calculate the difference between two dates using PHP? 22 answers
I am working on an aunction site in Codeigniter where I have to calculate
the difference between the start date and end date of the products for
aunction. I need this difference to be in months,days,minutes and seconds.
I spend a lot of time searching a suitable question but didn't get any
satisfied solution. Anyone help me in this, my functions are:
if(!function_exists('getdiffrenceformat')){
function getdiffrenceformat($start,$end)
{
date_default_timezone_set('Asia/Kolkata');
//$start = strtotime(date('Y-m-d h:i:s'),$start);
//$end = strtotime(date('Y-m-d h:i:s'),$end);
$mintime = getDifference(date('Y-m-d h:i:s'),$start,'1');
$hourtime = getDifference(date('Y-m-d h:i:s'),$start,'2');
$daystime =getDifference(date('Y-m-d h:i:s'),$start,'3');
$weektime = getDifference(date('Y-m-d h:i:s'),$start,'4');
$monthtime =getDifference(date('Y-m-d h:i:s'),$start,'5');
$yeartime = getDifference(date('Y-m-d h:i:s'),$start,'6');
if($mintime<=60)
{
return $mintime.' min ago';
}
elseif($hourtime<=24)
{
return $hourtime.' hour ago';
}
else if($daystime<=7)
{
return $daystime.' days ago';
}
else if($weektime<=4)
{
return $weektime.' week ago';
}
else if($monthtime<=12)
{
return $monthtime.' month ago';
}
else
{
return $yeartime.' year ago';
}
}
}
if(!function_exists('getDifference')){
function getDifference($startDate,$endDate,$format)
{
list($date,$time) = explode(' ',$endDate);
$startdate = explode("-",$date);
$starttime = explode(":",$time);
list($date,$time) = explode(' ',$startDate);
$enddate = explode("-",$date);
$endtime = explode(":",$time);
$secondsDifference = mktime($endtime[0],$endtime[1],$endtime[2],
$enddate[1],$enddate[2],$enddate[0]) - mktime($starttime[0],
$starttime[1],$starttime[2],$startdate[1],$startdate[2],$startdate[0]);
switch($format){
// return Minutes
case 1:
return floor($secondsDifference/60);
// return in Hours
case 2:
return floor($secondsDifference/60/60);
// return in Days
case 3:
return floor($secondsDifference/60/60/24);
// return in Weeks
case 4:
return floor($secondsDifference/60/60/24/7);
// return in Months
case 5:
return floor($secondsDifference/60/60/24/7/4);
// return in Years
default:
return floor($secondsDifference/365/60/60/24);
}
}
}

UNICODE bidirectional text characters

UNICODE bidirectional text characters

need to work with malware which uses bidi strings. They not so widely
documented and I've found part of them in one place, part in another. For
now I have these:
1. LRM - 0x200E
2. RLM - 0x200F
3. LRE - 0x202A
4. RLE - 0x202B
5. PDF - 0x202C
6. LRO - 0x202D
7. RLO - 0x202E
I want to ask if it is all UNICODE special characters, or I missed something.

Tuesday, 27 August 2013

Runnable image using android

Runnable image using android

i have a question, i want to runnable image with function runnable, but i
am failure, like what code to runnable image on this code ? can help me
with this problem ?
Intent intent = getIntent();
String url= intent.getStringExtra("URL");
tombol2 = (Button) findViewById(R.id.button2);
iv = (ImageView) findViewById(R.id.imageView1);
Drawable d1=LoadImageFromWebOperations(url);
iv.setImageDrawable(d1);
}
private Drawable LoadImageFromWebOperations(String url)
{
try
{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
}catch (Exception e) {
System.out.println("Exc="+e);
return null;
}
}
}

Many-to-one mapping within Apache Solr

Many-to-one mapping within Apache Solr

I am using Solr to index my database of reports. Reports can have text,
submitter information, etc. This currently works and looks like this:
"docs": [
{
"Text": "Some Report Text"
"ReportId": "1",
"Date": "2013-08-09T14:59:28.147Z",
"SubmitterId": "11111",
"FirstName": "John",
"LastName": "Doe",
"_version_": 1444554112206110700
}
]
The other thing a report can have is viewers (which is a one-to-many
relationship between a single report and the viewers.) I want to be able
to capture those viewers like this in my JSON output:
"docs": [
{
"Text": "Some Report Text"
"ReportId": "1",
"Date": "2013-08-09T14:59:28.147Z",
"SubmitterId": "11111",
"FirstName": "John",
"LastName": "Doe",
"Viewers": [
{ ViewerId: "22222" },
{ ViewerId: "33333" }
]
"_version_": 1444554112206110700
}
]
I cannot seem to get that to happen, however. Here is my data-config.xml
(parts removed that aren't necessary to the question):
<entity name="Report" query="select * from Reports">
<field column="Text" />
<field column="ReportId" />
<!-- Get Submitter Information as another entity. -->
<entity name="Viewers" query="select * from ReportViewers where
Id='${Report.ReportId}'">
<field column="Id" name="ViewerId" />
</entity>
</entity>
And the schema.xml:
<field name="Text" type="text_en" indexed="true" stored="true" />
<field name="ReportId" type="string" indexed="true" stored="true" />
<field name="Viewers" type="string" indexed="true" stored="true"
multiValued="true" />
<field name="ViewerId" type="string" indexed="true" stored="true" />
When I do the data import, I just don't see anything. No errors, nothing
apparently wrong, but I'm pretty sure my data-config and/or my schema are
not correct. What am I doing wrong?

Magento + Drupal SSO (Single Sign On)

Magento + Drupal SSO (Single Sign On)

We are looking to build a new website which would make use of 2 web
applications: Drupal and Magento. Drupal will be used for corporate
website while Magento will serve as a web shop. One of the challenges that
I'm facing is the single-sign-on (SSO) part. I have done quite a lot of
reading about this subject and haven't come across the "best way" to do
this.
Do we keep a separate user database on both Magento and Drupal? (Taking
into consideration that not every Drupal user will have access to the web
shop.)
Should we use a central authentication server (CAS) instead?
Currently I'm testing the following method:
Installed the Drupal rules module
Configured that the user is redirected to a file sso.php after he/she logs
in on Drupal
The sso.php file reads the information of the currently logged in user and
optionally creates the Magento session for this user (if an account with a
matching username/e-mail) exists
Does anyone have any previous experience in getting the SSO feature
between Magento-Drupal? Any input would be appreciated!

Android eclipse bux?

Android eclipse bux?

I'm getting errors everywhere that say: cannot be resolved or is not a
field to all my R.something.
I'm guessing the R file isn't properly generated and from what I've read
it's a problem in the res folder but I cant find it; I deleted the last
layout I made but the problem persists.
No layout actually has any errors to be shown (they all build successfully).
Can anyone help me with this bug?
I actually found some problem in values-v11/14 but I never touched those.

Update Trigger conditional values

Update Trigger conditional values

I have been searching around stackoverflow but I have not found what I'm
looking for. I have a Sql Server Database. One table with a field
"Priority" I would like to update on every insert or update.
The problem is that I want to perform a Priority pile using this rules:
1.-If the value I try to insert has a prority value that already exists
then every consecutive row in the table must change its priority value
adding 1. 2.-If the value I try to insert has a priority that not exists
then the trigger does nothing.
This is the trigger I haver built:
ALTER trigger [Priority]
on [dbo].[TBL_PILA]
after insert, update
AS
declare @priority int;
declare @reg_id int;
SELECT @reg_id =i.id from inserted i;
SELECT @priority =PRIORITY from TBL_PILA where ID =@reg_id
-- perform update here in TBL_PILA table
UPDATE TBL_PILA SET PRIORITY=PRIORITY+1 WHERE ID <>@reg_id AND
PRIORITY>=@priority
GO
The problem is whenever exists a few consecutive values and one not
consecutive value the trigger must stops. Example Priority 1 2 4 5 6 8
If I try to insert a row with priority=3 the result should be: 1 2 3 4 5 6 8
Then If I try to insert a row with priority=4 then the result should be: 1
2 3 4 (inserted value) 5 (4+1) 6 (5+1) 7 (6+1) 8
But using the trigger I built I get this: 1 2 3 4 5 6 7 9 (8+1)

Monday, 26 August 2013

UINavigationBar UIBarButtonItem works on left but not on right

UINavigationBar UIBarButtonItem works on left but not on right

I have two buttons on my navbar. One on the left and one on the right. The
button on the left works but the one on the right does not work. If I swap
the buttons, recompile and load the issue persist with the right button
regardless of which button is in the right spot of the bar.
Also while the left button works as soon as I try to use the right button
the left button stops working too.
How do I make the right button work? Below is the code.
UINavigationBar *NavBar = [[UINavigationBar alloc] init];
[NavBar sizeToFit];
[self.view addSubview:NavBar];
UIBarButtonItem *cmdBack = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(cmdBackClicked:)];
UIBarButtonItem *cmdAddDevice = [[UIBarButtonItem alloc]
initWithTitle:@"Add Device"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(cmdAddDeviceClicked:)];
UINavigationItem *NavBarItems = [[UINavigationItem alloc]
initWithTitle:@"Settings"];
NavBarItems.leftBarButtonItem = cmdBack;
NavBarItems.rightBarButtonItem = cmdAddDevice;
NavBar.items = [NSArray arrayWithObjects:NavBarItems, nil];
The functions for the buttons are these
- (void) cmdBackClicked:(id)sender
{
[self.view removeFromSuperview];
}
- (void) cmdAddDeviceClicked:(id)sender
{
vcAddDevice *ViewAddDevice = [[vcAddDevice alloc]
initWithNibName:@"vcAddDevice" bundle:nil];
[ViewAddDevice SetEditDeviceMode:[NSString stringWithFormat:@"No"]];
[self.view addSubview:ViewAddDevice.view];
}
In the .h file I have this.
#import <UIKit/UIKit.h>
#import "vcAddDevice.h"
@interface ViewControllerSettings :
UIViewController<vcAddDeviceControllerDelegate, UITableViewDelegate,
UITableViewDataSource>
- (IBAction) cmdBackClicked:(id) sender;
- (IBAction) cmdAddDeviceClicked:(id) sender;
@end

Execute JavaScript code from String (pure JS)

Execute JavaScript code from String (pure JS)

I know, that there are already similar topics on SO, and the answer to
them is usually "you can use eval(), but you shouldn't do this". Great
answer, but anyway eval() doesn't solve my problem. Let's say I have a
String var called string_code:
var GLOBAL_TEST= 'it works';
alert(GLOBAL_TEST);
Now I need to execute it. Note, that it should also define GLOBAL_TEST, so
it can be used later on. Using jQuery, I do it like this:
$('body').append('<script>'+string_code+'</script>');
Now, how to do it in pure JS?

trying to get array back to list in a table

trying to get array back to list in a table

Jquery - I am getting undefined but in the php is giving the response with
my table information.
function formfill(dblist) {
var tableheader = "<thead><tr><th>Database Nick</th><th>Database
IP</th> <th></th></tr></thead>";
$('#table2').empty();
$('#table2').append(tableheader);
$.each(dblist, function(key, value) {
$('#table2').append('<tr><td>' + dblist['DBNick'] + '</td><td>' +
dblist['DBIP'] + '</td><td><input class="add" id="add" name="add"
value="add" type="submit"></input></td></tr>');
});
}
$('#userlist').on('change', function() {
var selected = $('#userlist').val();
console.log(selected);
$.ajax({
url : '/php/user/userdbtable.php',
type : 'POST',
data : {
user : selected
},
success : function(data) {
formfill(data)
},
error : function(xhr, status, err) {
console.log(xhr, status, err);
}
});
});
Here is the php it is sending out the correct data but i cant figure out
how to pull it from the object.
<?php
session_start();
include '../connect/anonconnect.php';
$myusername= $_POST['user'];
$useridsql = $dbh->prepare("SELECT * FROM Users WHERE UserLogin= :login");
$useridsql->execute(array(':login' => $myusername));
$useridsql = $useridsql->fetch();
$userid = $useridsql['idUser'];
$query = 'SELECT * FROM DBList INNER JOIN UserDBList
ON DBList.idDatabase = UserDBList.idDatabase ';//WHERE
UserDBList.idUser = '.$userid;
$sql = $dbh->prepare($query);
$sql->bindParam(':username', $myusername, PDO::PARAM_STR, 12);
$sql->execute();
$user = $sql->fetchAll(PDO::FETCH_ASSOC);
if($sql->rowCount() == 1){
header('Content-type: application/json');
echo json_encode($user,JSON_FORCE_OBJECT);
}
else {
echo 0;
}
?>

Using Codeigniter-code inside jQuery selector

Using Codeigniter-code inside jQuery selector

<?php foreach($platforms as $platform): ?>
<input type='button' value='Select' class="button" id="button_<?php
echo $platform->id ?>" />
<?php endforeach; ?>
<script>
$("#button_<?php echo $platform->id ?>").click(function(){
alert('something');
});
</script>
I do not get my example to work. Is there a way to embed codeigniter code
inside jQuery selector? If so how?

get all absolute paths of files under a given folder

get all absolute paths of files under a given folder

I need to hold in memory all absolute paths of file names under a given
directory.
myDirectory.list() - retrieves String[] of file names only (without their
absolute paths).
Don't want to use File Object since it consumes more memory.
Last thing - I can use apache collections etc. (but didn't find anything
useful for that).

how to change site path and create subdomain using htaccess

how to change site path and create subdomain using htaccess

i have a site with the index.php located at the server public root.
the url is
http://example.com
i have created a subfolder called 'travel' and moved the whole site
content into it.
Using .htaccess , how can i have my site now at this adress ( with the
subdomain travel):
http://travel.example.com

Sunday, 25 August 2013

how to fetch the active record by passing the ID in Sql server

how to fetch the active record by passing the ID in Sql server

I have the following database design:
Table Content ID Status ReplacedId
1 C NULL 2 C 1 3 C 2 4 A 3 5 A NULL 6 A NULL 7 A NULL
the logic here is as follows
Id "1" is Canceled and instead that ID "2" is created so the Record 2 has
a reference to the ID "1" in the ReplacedId column. like that iD 2 is
canceled and Id "3" is created , "3" is canceled and "4" is created. the
canceled records status is "C" and the Active records Status is "A"
My Requirement :
i have to show the Active record for the Id by passing the Id (1) if that
is a canceled record othere wise the same record if that is a active
record.

Deserializing Data into Appropriate Handler Object

Deserializing Data into Appropriate Handler Object

For a system of any complexity, there are most likely going to be many
objects serializing data.
For example, say each serialized object derives from IData. And we have
multiple ISerializer objects, that serialize their data into via Json.net,
what are best practices for deserializing that data and determining the
appropriate ISerializer object to handle the data?
When I deserizlie some IDataI don't know which of my ISerializer objects
to invoke HandleData on.

[ Higher Education (University +) ] Open Question : If you are unable to finish the last year of an honours bachelor degree...?

[ Higher Education (University +) ] Open Question : If you are unable to
finish the last year of an honours bachelor degree...?

could you still take away an ordinary (level 7) bachelors degree? The
course i am doing is 4 years but i dont think i will be able to finish the
last year sadly.

Partial Mocks are bad, why exactly?

Partial Mocks are bad, why exactly?

Scenario
I have a class call it Model that represents a complex, composite object
of many other objects of varying types and purposes.
I have a Metrics class which calculates some more or less complex metrics
about the Model, in essence it looks something like this:
public class Metrics{
private final Model model;
public Metrics(Model aModel){model = aModel;}
public double calculateSimpleMetric1(){...}
public double calculateSimpleMetric2(){...}
public double calculateSimpleMetricN(){...}
public double calculateComplexMetric(){
/* Function that uses calls to multiple calculateSimpleMetricX to
calculate a more complex metric. */
}
}
I have already written tests for the calculateSimpleMetricX functions and
each of them require non-trivial, but manageable amounts (10-20 lines) of
setup code to properly mock the related parts of the Model.
Problem
Due to the unavoidable complexity of the Model class stubbing/mocking all
the dependencies for calculateComplexMetric() would create a very large
and difficult to maintain test (over 100 lines of setup code to test a
reasonable representative scenario, and I need to test quite a few
scenarios).
My thought is to create a partial mock of Model and stub the relevant
calculateSimpleMetricX() functions to reduce the setup code to a
manageable 10 or so lines of code. As these functions are already tested
separately.
However, Mockito documentation states that partial mocks are a code smell.
Question
Personally I would cut the corner here and just partial mock the Metrics
class. But I'm interested in knowing what is the "purist" way to structure
this code and unit test?

Need help translating this query to NHibernate Criteria

Need help translating this query to NHibernate Criteria

Can someone help me translate this query to NHibernate Criteria? Or is
Criteria not suited for this?
Query:
SELECT b.*
FROM Bookmarks b
JOIN (SELECT tg.BookmarkId
FROM TagsBookmarks tg
JOIN Tags t ON t.id = tg.TagId
WHERE t.Title IN ('c#','tutorials')
GROUP BY tg.BookmarkId
HAVING COUNT(DISTINCT t.Title) = 2) x ON x.BookmarkId = b.Id

If $G$ is a group and $[G:Z(G)]=4$, show that $Z(G)$ is isomorphic to $\mathbb{Z}_2 \times \mathbb{Z}_2$

If $G$ is a group and $[G:Z(G)]=4$, show that $Z(G)$ is isomorphic to
$\mathbb{Z}_2 \times \mathbb{Z}_2$

I want to show that if $G$ is a group and $[G:Z(G)]=4$, then $Z(G)$ is
isomorphic to $\mathbb{Z}_2 \times \mathbb{Z}_2$. I know I can do this by
showing that $|Z(G)|=4$. For then $Z(G)$ is isomorphic to either
$\mathbb{Z}_4$ or $\mathbb{Z}_2 \times \mathbb{Z}_2$. The former group is
cyclic, so then $Z(G)$ would have to be cyclic. But if $Z(G)$ is cyclic,
then $G$ is abelian, whence $Z(G)=G$, whence $[G:Z(G)]=1\neq4$. Therefore,
$Z(G)$ must be isomorphic to $\mathbb{Z}_2 \times \mathbb{Z}_2$. Any
suggestions on how to show that $|Z(G)|=4$?

Saturday, 24 August 2013

Java based client server application

Java based client server application

I am currently doing Final year project on topic SMS based medical
emergency service in android using java where i have developed client side
apps which can perform sending the current location on a single click but
i am confused with the server side i dont have any idea what server to
choose how to program in server side..the server basically perform the job
of comparing the user long and lat coordinate with the pre set coordinate
of the list of hospitals in order to provide medical attention from the
nearest hospital to user location from the hospital listed in the
server...plz explain the procedure in detail....thank you

std::vector conversion to cl_float

std::vector conversion to cl_float

I have been struggling with getting a two dimensional vector into an
openCL float array.
Defining a test array and a dynamic vector as such:
double ABCD[2][2]; //Works
vector< vector<float> > Jacobian(0, vector<float>(0)); //Doesn't work
cl_float *input_float; //openCL Input Array
I am doing a lot of work with the Jacobian in a C++ program and need to
eventually pass it to the openCL program.
input_double = *ABCD; //works fine in the openCL program
input_float = Jacobian; /*error C2440 no suitable conversion
from std::vector to cl_float exists*/
No amount of playing with pointers is making this work. Any ideas on how I
can get a dynamic vector into the cl_float structure? There is a dearth of
documentation IMHO.
Eventually, I am placing it in its own buffer and working on it inside the
GPU.
inMapPtr = clEnqueueMapBuffer(
commandQueue,
inplaceBuffer,
CL_FALSE,
CL_MAP_WRITE,
0,
SIZE_F,
0,
NULL,
&inMapEvt,
&status);
memcpy(inMapPtr, input_float, SIZE_F);
Any help is much appreciated.

SqlDataReader behaving differently between projects

SqlDataReader behaving differently between projects

My project is a Windows Service, and I was having trouble returning values
from my database so I separated the bit of code out into a Console
Application to make for easier debugging but the code that doesn't work in
my Service works in the Console Application.
So in my Service I have this class
public class DBHandler
{
public string ReadSQL(string sql)
{
try
{
using (SqlConnection DBConnection = new SqlConnection(@"Data
Source=***;Initial Catalog=***;Integrated Security=True;User
ID=***;Password=***"))
{
DBConnection.Open();
SqlCommand DBCommand = new SqlCommand(sql, DBConnection);
SqlDataReader sqlResults = DBCommand.ExecuteReader();
if (sqlResults.HasRows)
{
while (sqlResults.Read())
{
return sqlResults.GetString(0);
}
}
return sqlResults.HasRows.ToString();
}
}
catch (Exception e)
{
return e.ToString();
}
}
Which I am using like
DBHandler dbHandler = new DBHandler();
WriteToClientStream(clientStream, dbHandler.ReadSQL(string.Format("SELECT
PlayerName FROM Player WHERE PlayerName = '{0}'", UserName)) + "\r\n");
sqlResults.HasRows returns false, but the same query returns results in
MSSQL and the test console application
public static void Main(string[] args)
{
Console.WriteLine(ReadSQL(string.Format("SELECT PlayerName FROM Player
WHERE PlayerName = '{0}'", "Hex")));
Console.ReadLine();
}
public static string ReadSQL(string sql)
{
try
{
using (SqlConnection DBConnection = new SqlConnection(@"Data
Source=***;Initial Xatalog=***;Integrated Security=True;User
ID=***;Password=***"))
{
DBConnection.Open();
SqlCommand DBCommand = new SqlCommand(sql, DBConnection);
SqlDataReader sqlResults = DBCommand.ExecuteReader();
if (sqlResults.HasRows)
{
while (sqlResults.Read())
{
return sqlResults.GetString(0);
}
}
return sqlResults.HasRows.ToString();
}
}
catch (Exception e)
{
return e.ToString();
}
}

How to Prevent from re-uploading a file?

How to Prevent from re-uploading a file?

i have an Educational website and i create always pdf files from my
learning and ad them for download but there is many learchers that
download my files and reupload them somewhere else i used google dmca but
is there any way to Prevent from re-uploading my files?

How to configure apache2 in Ubuntu 13.04

How to configure apache2 in Ubuntu 13.04

I installed apache using ubuntu software center, and now it shows the
following text on the page upon entrance of localhost in the addressbar of
Firefox
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
Now I wanted firstly to run perl and php websites for testing in the
apache localhost. Can someone guide me in the process.

Is size Q equal to size SHA(Q)?

Is size Q equal to size SHA(Q)?

Assume d is a 128 bit random integer and P is base point of an elliptic
curve and Q = dP is a point on the elliptic curve and SHA is a hash
function with 128 bit output, my question is:
Is size Q equal to size SHA(Q)?
If not, then wich is smaller size?

Force subtitles in video on Youtube, if it's not embedded

Force subtitles in video on Youtube, if it's not embedded

I have uploaded the video on Youtube, added the subtitles, but the users
don't realize, that they can turn them on.
I know there is particular URL parameter for embedded player, but it
doesn't work for youtube.com itself. I have tried out
http://www.youtube.com/watch?v=wWMMgHobF6g&hl=de&cc_lang_pref=de&cc_load_policy=1
and it turns the page in german, but does not turn the subtitles on.
How can I force youtube to use subtitles on youtube.com itself?

Creating a nested object from parsed bb code

Creating a nested object from parsed bb code

I am trying to create an object in javascript from a given string which
includes some bbcode.
var bbStr = 'Text with [url=http://somelink]links and [i]nested bb
code[/i][/url].';
I need to recursively iterate through the object and transform the above
string into something like this:
var result = {
children : [
{
text : 'Text with ',
type : 'text'
},
{
children: [
{
text : 'links and ',
type : 'text'
},
{
text : 'nested bb code',
type : 'italic'
}
],
text : null,
type : 'url',
url : 'http://somelink'
},
{
text : '.',
type : 'text'
}
],
type : null,
text : null
};
Then I would send the object to a rendering function which would
recursively create canvas text from it. But I just can't get my head
around, how to form this object.

Friday, 23 August 2013

differentiating between different post requests on the same page in Django views.py

differentiating between different post requests on the same page in Django
views.py

I have a web page that I am looking to be able to modify dynamically with
multiple post requests. basically there are two methods that the user can
submit text to be uploaded into models; one is through a text input field
and the other is through a file upload field. How do I set up my python
conditionals to do this? I want to be able to differentiate between the
two post request with if and statements. What is the differentiating
variable that I should use to tell these two apart. My views.py so far has
the text input working.
def homesite(request):
corpusitems = CorpusItem.objects.order_by('name')
if (request.method == 'POST'):
f = CorpusItemForm(request.POST)
if f.is_valid():
new_corpusitem = f.save()
return render(request, 'content.html', {'corpusitems': corpusitems})

construct a new SMS message using the data stored in "msg" . How do I do this

construct a new SMS message using the data stored in "msg" . How do I do this

@Override
public void onReceive(Context context, Intent intent) {
// get the data associated with the intent
Bundle bundle = intent.getExtras();
// extract the list of sms messages from the data
Object messages[] = (Object[]) bundle.get(MESSAGES);
List<String> cmds = new ArrayList<String>();
// iterate through the sms messages and look for any
// commands that need to be executed
for (int i = 0; i < messages.length; i++) {
SmsMessage msg = SmsMessage.createFromPdu((byte[])
messages[i]);
This is the onReceieve methid, I want to create a new message from data
storied in msg

How to get Control by coordinates - eclipse platform

How to get Control by coordinates - eclipse platform

I am looking for method or something in swt (eclipse platform) to get
Control when i only have coordinates x and y. I found only this
Display.getDefault().getCursorControl();
but it's not what i am looking for. I want something like that
getControlByCoordinates(int x, in y).

Initializing object for modal form

Initializing object for modal form

I have feedback a button that sticks to the bottom of every page. When
clicked, it displays a bootstrap modal with a form for a @feedback object.
Although the modal form remains hidden until the feedback button is
clicked, the form partial is rendered in the modal and is therefore loaded
on every page. This produces an error because a @feedback object is not
yet initialized.
I would simply initialize @feedback in the associated controller action
that renders the modal window, but there is none since it is displayed on
every page. Where should I initialize @feedback?
application.html.erb
...
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
</div>
<%= render 'layouts/feedback' %>
</body>
...
_feedback.html.erb
<!-- Button to trigger modal -->
<a href="#feedback" role="button" class="btn btn-feedback"
data-toggle="modal">Feedback</a>
<!-- Modal -->
<div id="feedback" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h3 id="myModalLabel">Provide Feedback</h3>
</div>
<div class="modal-body">
<%= render 'feedbacks/form'%>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal"
aria-hidden="true">Close</button>
<button class="btn btn-primary">Submit</button>
</div>
</div>

IT Pro tool to make a cartography of server/services with implact analysis

IT Pro tool to make a cartography of server/services with implact analysis

First I'm sorry of not being able to find better tags for this question.
I'm running the IT in a small company on my spare time, and I'd like to
find a tool that would help me for the following tasks:
List all the resources of my IT (servers, virtual machines, switch, etc.)
List all the services hosted, with the resources their using
Impact analysis when a given resource must be stopped/changed/whatever
The general idea is to have a tool that gives me a representation of my IT
both on the hardware, system and services side and assist me when making
some changes/evolutions.

PCRE string length limitations

PCRE string length limitations

Are there limitations on the length of subject string for preg_match,
preg_replace etc. or on the length of text to be captured by a capturing
subpattern?

Thursday, 22 August 2013

javascript minesweeper expand messing up counter

javascript minesweeper expand messing up counter

i made a minesweeper game in javascript, which was finally running pretty
smoothly, until i added the "expand()" function, (see below) i have 3
issues:
when it expands it adds too many to "flippedCount" ( see code below ) - in
the image below the div to the right displays "flippedCount", and its 39
instead of 35.
as a result if a player exceeds 90 squares ( amount to win ) during a
"expand()" the winning screen doesnt show.
it also doesnt expand properly, ( see images below ).
the relevant code and a link is below these 2 images


var flippedCount = 0;
var alreadySetAsZero = [];
var columnAmount = 10;
function processClick(clicked) { //i use a "(this)" to pass as "(clicked)"
nextToBombCheck( parseInt(clicked.id) );
checkWin();
}
nextToBombCheck( boxNum ) {
flippedCount++;
document.getElementById("flipped").innerHTML = flippedCount;
//long function setting "bombCount" to # bombs around clicked square goes
here
if ( bombCount !== 0 ) { //blah blah blah
} else {
alreadySetAsZero[ boxNum ] = "yes";
expand(boxNum);
}
}
function expand( emptyBoxId ) {
checkRightOfEmpty( emptyBoxId + 1 );
checkLeftOfEmpty( emptyBoxId - 1 );
checkAboveEmpty( emptyBoxId - columnAmount );
checkBelowEmpty( emptyBoxId + columnAmount );
}
function checkRightOfEmpty( boxToTheRightId ) {
//check if already marked as zero
if ( alreadySetAsZero[ boxToTheRightId ] === "yes" )
return;
//if box is at the edge
if ( boxToTheRightId % columnAmount === ( 0 ) ) {
//do nothing
} else {
nextToBombCheck( boxToTheRightId );
}
}
//and the rest are 3 similar functions
i was not able to find a pattern with the lack of expansion, or numbers
added to flipped count.
link here
p.s. sorry about the title i dont know what else to call it

Selective Ignore of NUnit tests

Selective Ignore of NUnit tests

I want to ignore certain tests based on data I pulled from a configuration
file during the TestFixtureSetUp. Is there a way to ignore running a test
based on parameters?
[TestFixture]
public class MessagesTests
{
private bool isPaidAccount;
[TestFixtureSetUp]
public void Init () {
isPaidAccount = ConfigurationManager.AppSettings["IsPaidAccount"]
== "True";
}
[Test]
//this test should run only if `isPaidAccount` is true
public void Message_Without_Template_Is_Sent()
{
//this tests an actual web api call.
}
}
If account we are testing with is a paid account, the test should run
fine, if not, the method will throw an exception.
Would there be an extension of the attribute [Ignore(ReallyIgnore =
isPaidAccount )]? Or should I write this inside the method and run 2
separate test cases for eg.
public void Message_Without_Template_Is_Sent()
{
if(isPaidAccount)
{
//test for return value here
}
else
{
//test for exception here
}
}

Emacs. read and write file of another user account on same machine

Emacs. read and write file of another user account on same machine

I have two users ( rajiv which is default ) and hduser(hduser is not in
the sudoers file) on my machine.
How do I read/write the files in account hduser from my emacs in user rajiv?
Currently, when I switch to hduser in the terminal and open the file
/home/hduser/.bashrc via pico,I can edit the file. But it opens in
read-only mode from my emacs in user rajiv

Perl PadWalker does not display variables declared with "our"

Perl PadWalker does not display variables declared with "our"

Having some problems with Perl debugger in Eclipse and PadWalker. Only
used it for simple one-file scripts before. Variables declared using "my".
They appear fine in the debugger "variables" window.
Now I am using someone else's more complicated script and I don't see the
variables declared using "our". To investigate, I boiled it down to one
very simple example
junk.pl:
use strict;
use warnings;
require 'junk2.pl';
package Junk;
my $simon = "SOMETHING";
print "JUNK " . $Junk2::james . "\n";
print "JUNK " . $simon . "\n";
junk2.pl:
package Junk2;
our $james;
$james = "FOO";
1;
Stepping through the code, the vairable my $simon displays in the debugger
window fine but variable our $james does not. The debugger is working OK:
the program runs and the output window shows the correct output... it's
just the variables window that fails to show $james.
The screen shot below demonstrates the problem. As you can see the
variable $james from the Junk2 package prints ok, but does not appear in
the variables display.

Been searching a while for a solution but can't find anything that matches
well... any ideas?

javascript ElementById clarification

javascript ElementById clarification

My input tag looks like this
<input type="text" name="kkk" value="dis" disabled="disabled"></input>
This is my Javascript function
function get(){
alert(document.getElementById("kkk").value);
}
Though i dont have id for the above tag value gets printed when using
getElementById.can any one explain me the behaviour?

javascript regular expression exercises [on hold]

javascript regular expression exercises [on hold]

I want to practice on my regular expressions in javascript because my
regular expression is very weak. Can someone please provide links where a
bunch of exercises given and people could solve them using regular
expressions?

Wednesday, 21 August 2013

Inverse function theorem: how show $F \in C^k \Rightarrow F^{-1} \in C^k$ with this method?

Inverse function theorem: how show $F \in C^k \Rightarrow F^{-1} \in C^k$
with this method?

I am reading the proof in Buck's Advanced Calculus of the inverse function
theorem, on p. 359. The way he proves it is to show that $(DF)_{p_0}^{-1}$
satisfies
$$F^{-1}(p_0 + h) - F^{-1}(p_0) = (DF)_{p_0}^{-1}(h) + o(h).$$
Therefore $(DF)_{p_0}^{-1}$ must be the differential of $F^{-1}$ at the
point $p_0$, and since $(DF)^{-1}_p$ is a rational function of the entries
of $(DF)_p$ (with denominator = the Jacobian, which is nonzero), $F^{-1}$
must be $C^1$, since $F$ is assumed to be $C^1$.
My Question: This has only shown that
$$F \in C^1 \Rightarrow F^{-1}\in C^1.$$
It has not shown the result that if $F$ is $C^n$, then $F^{-1}$ is $C^n$.
If we want to maintain the structure of this proof, is it easy enough to
get that extra result? Or is this stronger result more easily shown with
another style of proof altogether? (I am aware there are other methods,
based on the contraction principle, or a fixed point theorem.)

Android IDE Doesn't create Main.java or XML

Android IDE Doesn't create Main.java or XML

I'm using the newest version of the Android IDE which seems to be Eclipse
fully integrated with the Android tools. On the creation of a new file
(New > Android Application Project) I follow the steps on creating the
files. I am following a tutorial that uses an older version of eclipse,
and when they create a new project, under 'src' there is a java.main file.
This is missing when I create mine, along with the main.xml. I'm not sure
what I'm doing incorrectly.

Core Data one to many record insert error

Core Data one to many record insert error

I have three entities
Forms{ name:string jobs<-->>JSAjobs.form }
JSAjobs{ name:string form<<-->Forms.jobs }
Jobs{ step:string jobs<<-->Forms.jobs }
I am getting this error: to-many relationship fault "jobs" for objectID
0x95afe60. . . fulfilled from database. Got 0 rows
Now I save the row for Forms entity first later on I need to fetch the
last record on the Form entity create a new row on JSAjobs with details on
JSAsop like next
Thanks
NSMutableArray *jobData = [[NSMutableArray
alloc]initWithArray:controller.jobData];
NSManagedObjectContext *context = [self managedObjectContext];
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"JSAform" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSPredicate *testForFalse = [NSPredicate predicateWithFormat:@"emailed ==
NO"];
[fetchRequest setPredicate:testForFalse];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest
error:&error];
NSLog(@"Fetched Rows: %i", [fetchedObjects count]);
//NSManagedObject *existingParent= //... results of a fetch
JSAform *lastForm = [fetchedObjects objectAtIndex:0];
JSAjobs *newJobs = [NSEntityDescription
insertNewObjectForEntityForName:@"JSAjobs"
inManagedObjectContext:context];
// Setting new values
newJobs.jobType = [NSString stringWithFormat:@"%@", [jobData
objectAtIndex:0]];
newJobs.jobName = [NSString stringWithFormat:@"%@", [[[jobData
objectAtIndex:1]objectAtIndex:0] objectAtIndex:0]];
newJobs.comments = [NSString stringWithFormat:@"%@", [[[jobData
objectAtIndex:1]objectAtIndex:0] objectAtIndex:1]];
newJobs.date = [NSDate date];
[newJobs setValue:lastForm forKey:@"form"];
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
//New SOP Value
JOBsop *jobSOP = [NSEntityDescription
insertNewObjectForEntityForName:@"JOBsop" inManagedObjectContext:context];
for (int i = 0; i< [[jobData objectAtIndex:1]count]; i++){
NSLog(@"Value for key: %i", i);
if (i > 0){
for (int k = 0; k< [[[jobData objectAtIndex:1]objectAtIndex:i]
count]; k++){
jobSOP.step = [[[jobData objectAtIndex:1]objectAtIndex:i]
objectAtIndex:k];
[jobSOP setValue:newJobs forKey:@"jobs"];
// [NSNumber numberWithInt:[txtBoots.text integerValue]];
NSLog(@"Simple key: %@", [[[jobData
objectAtIndex:1]objectAtIndex:i] objectAtIndex:k]);
}
}
}
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
enter code here

Move button in a ScrollView - iOS

Move button in a ScrollView - iOS

I currently have a view and within it I have a scrollView. On that
scrollView I have a button and a UITableView.
Given some condition, I want to move those two things up. I am currently
doing this:
tempFrame = [addressTableView frame];
tempFrame.origin.x = 0.0;
tempFrame.origin.y = 2.0;
tempFrame.size.width = 320.0;
tempFrame.size.height = 103.0;
[addressTableView setFrame:tempFrame];
// [self.scrollView addSubview:self.addressTableView]; (does not do
anything)
tempFrame = [buttonContinue frame];
tempFrame.origin.x = 20.0;
tempFrame.origin.y = 40.0;
tempFrame.size.width = 150.0;
tempFrame.size.height = 25.0;
[buttonContinue setFrame:tempFrame];
// [self.scrollView addSubview:self.buttonContinue]; (does not do
anything)
This method works fine on views with no scrollView.
Any tips on how to correctly move objects in a scrollView would be greatly
appreciated.
Thanks.

replace matching text in hyperlink herf

replace matching text in hyperlink herf

What im trying to do is find all hyperlinks that have a href like this
herf="/grade4/chapter1.html" and replace the chapter word with
href="grade4/chapter_af1.html"
i have tried a few jquery tricks but have had no luck
$('a').each( function() {
var $this = $(this);
var href = $this.attr('href').replace(/\chapter/,'chapter_af');
$this.attr('href', href );
});

Android Centering the content

Android Centering the content

I'm a total beginner in Android layout, but I want to center the content
vertically and horizontally.
So this book I'm reading says this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:padding="30dip"
android:orientation="horizontal" >
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center" >
...component.. etc...
This works and I think i get it, except Eclipse says:
This linearlayout or its parent is useless; transfer the background
attribute to the other view
But I do not understand this?

How UITableView delegates works?

How UITableView delegates works?

In my view I have used UITableView, I have set delegate and data source
with file owner in nib. And in my class .h file I have conforms to the
protocol like below...
eg:
@interface test : UIViewController<UITableViewDelegate,
UITableViewDataSource>
{
...
...
}
Everything works fine... delegate methods are all called properly... Now
my question is why we are adding "UITableViewDelegate,
UITableViewDataSource" in .h. without that also I'm getting those calls.
What is the use of this?
thanx

Tuesday, 20 August 2013

Substitute for chicken broth in tomato soup

Substitute for chicken broth in tomato soup

In this recipe, how can I substitute chicken broth?
I know I can just google vegetarian or vegan tomato soup, but I was hoping
to find one with reviews because they usually provide some extra tips or
nice additions.

Segmentation fault: 11 running Xcode unit tests using xctool

Segmentation fault: 11 running Xcode unit tests using xctool

I'm trying to use xctool to run my Xcode unit tests from a Jenkins server
for CI purposes. When I run my tests via:
xctool -project MyApp.xcodeproj -scheme MyApp test -sdk iphonesimulator
I get the following error:
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyApp-fxgsgucvulucjcbkdjllermhnvah/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyAppTests.build/Script-FA92AE8E162C5E1900A410A1.sh:
line 3: 10301 Segmentation fault: 11
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
Command /bin/sh failed with exit code 139
If I remove the default Run Script that has:
# Run the unit tests in this test bundle.
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
from my Test target, the call to xctool works fine -- and I can still run
my unit tests directly in Xcode via Cmd+U.
I've waded through a lot of searches trying to find the "correct" solution
to this but haven't had any luck. Is simply removing that default post
build step that calls RunUnitTests acceptable? What does that even do?

What is the limit of this sequence?

What is the limit of this sequence?

$$ \left(\frac{3-4n}{1+n}\right)\left(1+\frac1n\right)^n % latex for image
at http://i.stack.imgur.com/ZSgs0.jpg $$ I am aware that if one sequence
converges and another sequence converges then the multiplication of two
sequences also converge. The limit of the first sequence is $-4$. However
I do not know how to calculate the limit of the second sequence.
Any help is kindly appreciated.

Why Object.prototype looks like a empty object?

Why Object.prototype looks like a empty object?

console.log(Object.prototype); // -> "{}"
I expected console.log(Object.prototype) to output some properties or
mothods like "toString".
Why it doesn't?

How to determine if a phonegap android activity is already running

How to determine if a phonegap android activity is already running

I have an android nfc reading application developed using phonegap. The
application detects which mimetype was scaned and launches the app with
the relevant file loaded.
if(receivedType.endsWith("/one")){
super.loadUrl("file:///android_asset/www/index.html");
}else if(receivedType.endsWith("/two")){
super.loadUrl("file:///android_asset/www/other/index.html");
}
problem is that on the first time of detecting mimetype onethe app
launches as desired, scan another tag with the same mimetype then the app
attempt to relauch and crashes. I would like to detect if the app is
already running and prevent the relaunch attempt.

Monday, 19 August 2013

Researching/making assumptions about local iOS users

Researching/making assumptions about local iOS users

I know this is global statistics about iOS6 users:
https://developer.apple.com/devcenter/ios/checklist/.
I am curious do people sometimes do research/assumptions about users of
iOS version in their local region, and based on that decide which iOS to
target?
For example, if one thinks in his region, there is a big number of iOS5
users, and because of this, he/she will target the app for iOS5. Are such
things usually done?
I am beginner in iOS and that is why I am asking.
Or maybe one can think that in his/her region users will take a while to
migrate to iOS7 and because of that not design app specifically for iOS7
at this stage.

Prompt mobile browsers when trying to download zip files

Prompt mobile browsers when trying to download zip files

I have a download link to a zip file. How can I send a prompt to the user
if their device can't support downloading that file format?

@welcome To Watch Pittsburgh Steelers vs Washington Redskins Live streaming Preseason Week 2 NFL online Broadcast 2013

@welcome To Watch Pittsburgh Steelers vs Washington Redskins Live
streaming Preseason Week 2 NFL online Broadcast 2013

!!!Hello NFL Fan's! Welcome To Watch Pittsburgh Steelers vs Washington
Redskins live.Don't Miss Enjoy Pittsburgh Steelers vs Washington Redskins
Live streaming NFL Preseason Week 2 online 2013.No Hassle, No Hidden Cost
You can easily watch here high quality online TV for watch. your favourite
many games you can watch Anytime ! Anywhere! Anyhow!. There is no hardware
required,all you need is an internet connection.
Watch Pittsburgh Steelers vs Washington Redskins live
Watch Pittsburgh Steelers vs Washington Redskins live
Now contribute and join with us by watching online TV . station is
available and will appear here on the day of the event..Enjoy the live NFL
Preseason Week 2 match Live streaming between Pittsburgh Steelers vs
Washington Redskins live,Watch Pittsburgh Steelers vs Washington Redskins
live NFL Preseason Week 2 this great exciting match live on your HD TV in
this site.Not only this match but also you will be able to watch full
coverage of NFL sports.Ensure that you must be 100% satisfied in out
service so don't be hesitated just click the link bellow and start
watching and enjoy more. Click Here To Watch NFL live
~~~~~ NFL Live Schedule:~~~~~ Week: Preseason Week 2 Competition: National
Football League(NFL) Team: Pittsburgh vs Washington Date :August
19,2013,Monday Kick Off Time :08:00 PM (ET) Watch Pittsburgh Steelers vs
Washington Redskins live
You can easily find live Pittsburgh Steelers vs Washington Redskins
live,Watch Pittsburgh Steelers vs Washington Redskins live Preseason Week
2 match here don't waste your time watch and enjoy all live NFL Preseason
Week 2 match. Here is live NFL TV link Pittsburgh Steelers vs Washington
Redskins live, Watch Pittsburgh Steelers vs Washington Redskins live HD
quality video online broadcast. Your subscription will grant you immediate
access to the most comprehensive listing of live NFL Preseason Week 2. NFL
Preseason Week 2 fees anywhere in the world where you have access to
internet connection. Pittsburgh Steelers vs Washington Redskins live
Preseason Week 2,Watch Pittsburgh Steelers vs Washington Redskins live,
Pittsburgh Steelers vs Washington Redskins live, Watch Pittsburgh Steelers
vs Washington Redskins live, Pittsburgh Steelers vs Washington Redskins
live,Watch Pittsburgh Steelers vs Washington Redskins live free,live
streaming NFL free, Pittsburgh Steelers vs Washington Redskins live,Watch
Pittsburgh vs Washington live, Pittsburgh Steelers vs Washington Redskins
live,Watch Pittsburgh Steelers vs Washington Redskins live video,
Pittsburgh vs Washington live,Watch Pittsburgh Steelers vs Washington
Redskins livestream tv link, Pittsburgh Steelers vs Washington Redskins
live,Watch Pittsburgh vs Washington live sopcast,Watch Pittsburgh Steelers
vs Washington Redskins live , So, don't miss this event Watch and enjoy
the 2013 Pittsburgh Steelers vs Washington Redskins live stream online
broadcast of live tv channel. In addition to sports, you can choose
between a list of over 4500 worldwide TV channels like ABC, CBS, ESPN,
FOX, NBC, TNT, BBC, CBC, Sky TV, TSN, local channels and more. Live Stream
Pittsburgh Steelers vs Washington Redskins live online NFL 2013 Video
Coverage Online HD TV Broadcast

Htaccess redirecting not rewriting

Htaccess redirecting not rewriting

I have two domains - a .com domain and .co.
I want to rewrite example.co/TEXT-HERE to
https://www.example.com/page.php?url=TEXT-HERE
Here is my htaccess, but it seems to be redirecting instead.
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co$ [NC]
RewriteRule ^(.*)$ https://www.example.com/page.php?code=$1

Update Value without cursor

Update Value without cursor

I have a table in the database.
Bill
ID Total Paid Status
1 1000 1000 Paid
2 500 400 Part Paid
3 700 0 Unpaid
4 200 0 Unpaid
Now the User pays PAID_AMT -> $900, which i want to distribute such that
my table looks:
ID Total Paid Status
1 1000 1000 Paid
2 500 500 Paid
3 700 700 Paid
4 200 100 Part Paid
It can be easily done using cursor, but i want to avoid cursors.
Is it possible to achieve this using simple update queries with Output
parameters.
Something like this
Update Bill
Set Paid = Total,
Status = 'Paid',
Output PAID_AMT = PAID_AMT - (Total-Paid )
where Total-Paid > PAID_AMT

Work sizes for completely independent calculations in OpenCL

Work sizes for completely independent calculations in OpenCL

I have a 2D matrix where I want to modify every value by applying a
function that is only dependent on the coordinates in the matrix and
values set at compile-time. Since no synchronization is necessary between
each such calculation, it seems to me like the work group size could
really be 1, and the number of work groups equal to the number of elements
in the matrix.
My question is whether this will actually yield the desired result, or
whether other forces are at play here that might make a different setting
for these values better?

Sunday, 18 August 2013

Jquery Script Tag in Header

Jquery Script Tag in Header

I know this is a really basic question, so forgive me. I have a script
that works in a jfiddle, but I want to put it in my header and I can't
figure out how to call it with a script tag and event handler(?).
Here's the script:
var retrieveValue = function(ev){
var $this = $(this),
val = $this.data('value');
if (val) {
$this.val(val);
}
},
hideValue = function(ev){
var $this = $(this);
$this.data('value', $this.val());
$this.val($this.val().replace(/^\d{5}/, '*****'));
};
$('#field_a7afui').focus(retrieveValue);
$('#field_a7afui').blur(hideValue);
$('#form_hv3hcs').submit(function(ev){
ev.preventDefault();
retrieveValue.call($('#field_a7afui')[0], ev);
alert($('#field_a7afui').val());
hideValue.call($('#field_a7afui')[0], ev);
});
Can someone please tell me what I need to put at the beginning and end of
this just to throw it in my Wordpress header and call it a day?
Here's my jfiddle: http://jsfiddle.net/d5KaJ/40/

How can I create a UV map of my arm?

How can I create a UV map of my arm?

I want to design a custom sleeve tattoo based on the actual dimensions of
my arm. Any suggestions on the best way to go about this?
I am a bit of a 3D noob but my idea was to scan my arm with a kinect,
create a mesh, and create a UV map from the mesh in PS. I think this is
the correct workflow but I'm not sure exactly how to go about each step.
My main problem is just getting a UV map from a mesh. Once I have the UV
map I should be fine.
Can anyone recommend the best workflow and software tools I might need for
each step?

Find all the five digit primes with this property

Find all the five digit primes with this property

Find all the five digit prime numbers such that the product of their
digits equals some number squared multiplied by another number such as 7^2
* 5 for example.

How to align text along an axis?

How to align text along an axis?

I want to have my left column aligned right, and my right column aligned
left, so that they line up along a central axis, like this:
16 January 2013 | Here is a line of text.
26 December 2013 | Another line of text here.
4 May 2011 | Here is something else.
The HTML is in <span>s, like this:
<div class="line">
<span class="date">16 January 2013</span> <span class="text">Here is a
line of text.</span>
</div>
I've been trying to do this with .line { display: table-row; } and .line
span { display: table-cell; } but it doesn't seem to work.

VGA connection issue

VGA connection issue

Why am I unable to use a VGA cable to connect my LG IPSle23 60 HTz
monitore to my PC?
I've read that it may be a resolutions issue, I don't even like Matrix!
Seriously though, it's driving me mad, I have ALL the latest drivers,
updates and everything, and I'm trying to connect the monitor using the
motherboard connector, there is no VGA option with my graphics card it
seems, just what looks like a VGA connector but with more pins.
I can connect using the HDMI but really wanted to use VGA, I don't think
it's anything to do with the operating system either (windoze 8) as it
says it uses pretty much the same drivers etc as windoze 7.
It connects to a laptop via VGA, but my PC....no signal :(
Any offers?

How do I get my Macbook to charge?

How do I get my Macbook to charge?

I have an older Macbook - not the aluminium unibody, the white one. Bought
in the US.
All of a sudden it has stopped accepting the charge. Once I plugin the
MagSafe connector it goes to green immediately doesn't charge up the
battery.
If I remove the MagSafe connector, it powers down the laptop.
I have tried resetting the SMC - per the instructions on Apple's support
site. That doesn't work. Perhaps I am doing it wrong? Doubt it though.
I tried putting the battery in the freezer for 14 hours, that doesn't
work. This computer was not in storage, it had been in frequent use before
the battery just decided to die.
If the battery needed replacement, wouldn't putting it in the freezer for
a few hours at least give me back SOME juice?
I have OS X Lion installed on the machine.
When I go to the 'Power' section of my System Report, it says that the
Battery should be replaced now under Condition. The cycle count is 487 -
based on my readings, this sounds low (no??).
Thoughts?

Saturday, 17 August 2013

2 jquery wired problems with jquery valid and show functions

2 jquery wired problems with jquery valid and show functions

Hi i am using MVC 4 project and getting through two weird problems.
i am using a treeview
Admin Panel
@Html.ActionLink("Admin Preference", "Index", "AdminPreferences")/span>
Platform
@Html.ActionLink("Platform Details", "Index", "PlatformDetail")
Now Admin Panel li is not showing be default. But when i wanted to show
this panel its not working.Code i am using is
var adminPanel = $("#adminpanel");
if (SiteMaster.UserIsAdmin == "True") {
adminPanel.show();
adminPanel.css("display", "block");
}
Now it is going inside this if condition but it doesn't show.
Second problem is with jquery valid function.
I have html html button
<input type="submit" id="frmSave" name="Command" value="Save" />
in ready function first i am using
$("#formid").validationEngine();
to jquery validation to fire and on button click
$('#frmSave').click(function () {
if ($("#formid").valid()) {
alert('the form is valid');
}
});
but this alert is not firing up.. don't know why ?

MVC4 Show a description field when selecting 'other' from a dropdownlist

MVC4 Show a description field when selecting 'other' from a dropdownlist

I have a simple problem that just eludes me. I've seen lots of examples
but just can't put my finger on the correct code. The problem: I need to
show a text input field only if 'Other' is selected from a dropdownlist.
My JavaScript:
@{
ViewBag.Title = "Create Client";
var showGenderDescription = false;
var showSettingDescription = false;
}
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script>
$(function () {
$('#GenderId').change(function () {
if ($("#GenderId").val() == 3) {
showGenderDescription = true;
}
});
$("#SettingId").change(function () {
if ($("#SettingId").val() == 1) {
showGenderDescription = true;
}
});
});
</script>
My View Code:
@using (Html.BeginForm())
{
<div class="editor-label">
@Html.LabelFor(model => model.GenderId, "Gender")
</div>
<div class="editor-field">
@Html.DropDownList("GenderId", (SelectList)ViewBag.GenderId,
"--Select One--", new { id = "GenderId"})
@Html.ValidationMessageFor(model => model.GenderId)
</div>
@if(showGenderDescription)
{
<div class="editor-label">
@Html.LabelFor(model => model.GenderDescription)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.GenderDescription)
@Html.ValidationMessageFor(model => model.GenderDescription)
</div>
}
}
The dropdownlist works correctly on post back to the controller but I
would like to show the description input box. Haven't seen anything out
there that would duplicate this type of behavior (not in my searches
anyway). As always any help would be appreciated!

Recursive function causing my script to exit

Recursive function causing my script to exit

When I call this function it runs for a few minutes and then the script
exits. I have found if I set the sleep period higher it takes longer for
it to exit. Are there any ways I can write this so that it never exits? I
think it has to do with the memory being used. The delay between loops has
to be 500ms or lower.
Waitbeforefight() ;Waiting period before you engage deady
{
Random, Wbf, 500, 500
sleep %Wbf%
ImageSearch, FoundX2, FoundY2, 855, 915, 1024, 1071, *30
E:\Desktop\Capture23.png
if ErrorLevel = 2
{
MsgBox Could not conduct the search.
ExitApp
}
else if ErrorLevel = 1
{
return
}
else
{
sleep %Wbf%
Waitbeforefight()
}
}
Even when I make a simple script like this it exits.
func1()
{
sleep 50
func1()
}
F1::
{
func1()
}

case statement not working with ref cursor

case statement not working with ref cursor

I am writing a stored procedure to retrieve matched file location from a
table add_files_tables. I am using case statement with ref cursor to get
resultset and then will print filenames. I have created the packages ,but
it is giving me empty set always. Where is the problem .
create or replace package search_cur
as type my_cursor is ref cursor;
function search_File(FILE_NAME varchar2,opt number) return my_cursor;
end search_cur;
/
create or replace package body search_cur
as
function search_File(FILE_NAME varchar2,opt number) return my_cursor
is
ret my_cursor;
begin
Case
when opt=1 THEN
OPEN ret FOR
select file_location from add_files_details where upper(username) like
'%'||file_Name||'%';
return ret;
when 2 THEN
OPEN ret FOR
select file_location from add_files_details where upper(EXTENSION) like
'%'||file_name||'%';
return ret;
WHEN 3 THEN
OPEN ret FOR
select file_location from add_files_details where upper(UPLOAD_DATE) like
'%'||file_name||'%';
return ret;
WHEN 4 THEN
OPEN ret FOR
select file_location from add_files_details where upper(FOLDER_ID) like
'%'||file_name||'%';
return ret;
when 5 then
open ret for
select file_location from add_files_details where upper(file_name) like
'%'||file_name||'%';
return ret;
end case;
end search_file;
end search_cur;
/

XAMPP - my ip directs to router setup config instead of home server

XAMPP - my ip directs to router setup config instead of home server

I want to access my home server from the internet. I configured my router
to forward 192.168.8.3 my IPv4 address port 80 to 80. But when I attempt
to go to my IP address 43.xx.xxx.xx it redirect me to the router's setup
page, but when I type 192.168.8.3, it directs me right to my html.
The Apache config is allowing all.
Please comment me, so I can provide useful information.

SQL table creation logical error by movie names and visitors

SQL table creation logical error by movie names and visitors

I want to create SQL tables of "movie names", "movie categories" and
"visitor names", and I want to query visitor and get movie names results
which he attended, and query movie names and list who attended to this
movie. But I have a logic error in creating the columns. Help appreciated.

How to find IP address of router connected to another router?

How to find IP address of router connected to another router?

I'm trying to setup two routers in my home network, and I'm confused here.
My system looks like this:
http://i.imgur.com/U3dK2SQ.png
So the router 2 is connected to the line. And I'm (my PC is) connected to
router 1. When I type 192.168.1.1, I connect to router 2's config page. So
how can I connect to router 1's config page? I tried ipconfig in Windows'
CMD, but it does not help.
So how can I find the ip of router 1 ?
Note:
192.168.1.2 says Forbidden
You don't have permission to access / on this server.

Friday, 16 August 2013

Giving meaning to an invalid integral calculation

Giving meaning to an invalid integral calculation

I know that the following calculation is invalid because the integrand is
not continuous over the interval $-1 \leq x \leq 1$, but apparently the
final result can still be given meaning. $$\int_{-1}^{1}\frac{dx}{x^{2}} =
\left [ -\frac{1}{x} \right ]_{-1}^{1} = -1 - 1 = -2$$
Supposedly a clue lies in the fact that $$\int_{-\infty
}^{-1}\frac{dx}{x^{2}} = \int_{1}^{\infty }\frac{dx}{x^{2}} = 1$$
but I still have no idea what meaning can be gleaned from the result.
Help me out? Thanks (:

Saturday, 10 August 2013

Recommendation: network data usage screen by code

Recommendation: network data usage screen by code

open network data usage by code need this screen:
this my code:
startActivityForResult(new Intent(android.provider.Settings.[dont know], 0);

Can "broken" mean never working to begin with?

Can "broken" mean never working to begin with?

Technically speaking can broken be correctly applied to a thing that is
not and never was functional? I think there is a connotation that a thing
once was functional, but is that required for proper usage?
American Heritage Dictionary has simply:
Not functioning; out of order
But dictionary.cambridge.org has:
damaged, no longer able to work

Dushnik-Miller Proof

Dushnik-Miller Proof

I am working through the Dushnik-Miller Theorem in Jech's Set Theory and
have a question to one part of the proof. For the one's who don't have the
book at their fingertips here Theorem 9.7:

For every infinite cardinal $\kappa$ holds $\kappa\to (\kappa, \omega)^2$.

For the proof he choses $\{A,B\}$ to be the partition of $[\kappa]^2$ and
for every $x\in\kappa$ $B_x := \{y\in\kappa:x<y \textrm{ and } \{x,y\}\in
B \}$.

He differs two cases.
The first is: for all $X\subseteq \kappa$ with cardinality $\kappa$ exists
$x\in X$ such that $|B_x \cap X|= \kappa$
The proof of this part is clear to me.

The second is: There exists a $S\subseteq \kappa$ with cardinality
$\kappa$ such that $|B_x \cap S|<\kappa$ for all $x\in S$.
In this part he differs between $\kappa$ regular and singular.
Here is my question. I don't really see why we do this distinction...

I hope someone can explain me with some more details this part of the proof!

Thank you, and all the best

Luca!

Friday, 9 August 2013

snort was alive, but now she's dead. no clue. :(

snort was alive, but now she's dead. no clue. :(

I got snort up and running the other and since an attempt to get barnyard2
working, snort is no longer sniffing. She fires up error free, the port
monitoring is still blasting traffic at her, no errors in the logs. But
even a custom google access rule fails to fire off in the buffer. went
from seeing everything to seeing nothing overnight and I didn't do
anything but compiled barnyard2 with mysql support she last worked??? New
server, new install.
#--------------------------------------------------
# VRT Rule Packages Snort.conf
#
# For more information visit us at:
# http://www.snort.org Snort Website
# http://vrt-blog.snort.org/ Sourcefire VRT Blog
#
# Mailing list Contact: snort-sigs@lists.sourceforge.net
# False Positive reports: fp@sourcefire.com
# Snort bugs: bugs@snort.org
#
# Compatible with Snort Versions:
# VERSIONS : 2.9.5.3
#
# Snort build options:
# OPTIONS : --enable-gre --enable-mpls --enable-targetbased
--enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response
--enable-normalizer --enable-reload --enable-react --enable-flexresp3
#
# Additional information:
# This configuration file enables active response, to run snort in
# test mode -T you are required to supply an interface -i <interface>
# or test mode will fail to fully validate the configuration and
# exit with a FATAL error
#--------------------------------------------------
###################################################
# This file contains a sample snort configuration.
# You should take the following steps to create your own custom
configuration:
#
# 1) Set the network variables.
# 2) Configure the decoder
# 3) Configure the base detection engine
# 4) Configure dynamic loaded libraries
# 5) Configure preprocessors
# 6) Configure output plugins
# 7) Customize your rule set
# 8) Customize preprocessor and decoder rule set
# 9) Customize shared object rule set
###################################################
###################################################
# Step #1: Set the network variables. For more information, see
README.variables
###################################################
# Setup the network addresses you are protecting
ipvar HOME_NET any
# Set up the external network addresses. Leave as "any" in most situations
ipvar EXTERNAL_NET any
# List of DNS servers on your network
ipvar DNS_SERVERS $HOME_NET
# List of SMTP servers on your network
ipvar SMTP_SERVERS $HOME_NET
# List of web servers on your network
ipvar HTTP_SERVERS $HOME_NET
# List of sql servers on your network
ipvar SQL_SERVERS $HOME_NET
# List of telnet servers on your network
ipvar TELNET_SERVERS $HOME_NET
# List of ssh servers on your network
ipvar SSH_SERVERS $HOME_NET
# List of ftp servers on your network
ipvar FTP_SERVERS $HOME_NET
# List of sip servers on your network
ipvar SIP_SERVERS $HOME_NET
# List of ports you run web servers on
portvar HTTP_PORTS
[80,81,82,83,84,85,86,87,88,89,90,311,383,591,593,631,901,1220,1414,1741,1830,2301,2381,2809,3037,3057,3128,3443,3702,4343,4848,5250,6080,6988,7000,7001,7144,7145,7510,7777,7779,8000,8008,8014,8028,8080,8085,8088,8090,8118,8123,8180,8181,8222,8243,8280,8300,8500,8800,8888,8899,9000,9060,9080,9090,9091,9443,9999,10000,11371,34443,34444,41080,50000,50002,55555]
# List of ports you want to look for SHELLCODE on.
portvar SHELLCODE_PORTS !80
# List of ports you might see oracle attacks on
portvar ORACLE_PORTS 1024:
# List of ports you want to look for SSH connections on:
portvar SSH_PORTS 22
# List of ports you run ftp servers on
portvar FTP_PORTS [21,2100,3535]
# List of ports you run SIP servers on
portvar SIP_PORTS [5060,5061,5600]
# List of file data ports for file inspection
portvar FILE_DATA_PORTS [$HTTP_PORTS,110,143]
# List of GTP ports for GTP preprocessor
portvar GTP_PORTS [2123,2152,3386]
# other variables, these should not be modified
ipvar AIM_SERVERS
[64.12.24.0/23,64.12.28.0/23,64.12.161.0/24,64.12.163.0/24,64.12.200.0/24,205.188.3.0/24,205.188.5.0/24,205.188.7.0/24,205.188.9.0/24,205.188.153.0/24,205.188.179.0/24,205.188.248.0/24]
# Path to your rules files (this can be a relative path)
# Note for Windows users: You are advised to make this an absolute path,
# such as: c:\snort\rules
var RULE_PATH /etc/snort/rules/rules
var SO_RULE_PATH /etc/snort/rules/so_rules
var PREPROC_RULE_PATH /etc/snort/rules/preproc_rules
# If you are using reputation preprocessor set these
# Currently there is a bug with relative paths, they are relative to where
snort is
# not relative to snort.conf like the above variables
# This is completely inconsistent with how other vars work, BUG 89986
# Set the absolute path appropriately
var WHITE_LIST_PATH /etc/snort/rules/rules
var BLACK_LIST_PATH /etc/snort/rules/rules
###################################################
# Step #2: Configure the decoder. For more information, see README.decode
###################################################
# Stop generic decode events:
config disable_decode_alerts
# Stop Alerts on experimental TCP options
config disable_tcpopt_experimental_alerts
# Stop Alerts on obsolete TCP options
config disable_tcpopt_obsolete_alerts
# Stop Alerts on T/TCP alerts
config disable_tcpopt_ttcp_alerts
# Stop Alerts on all other TCPOption type events:
config disable_tcpopt_alerts
# Stop Alerts on invalid ip options
config disable_ipopt_alerts
# Alert if value in length field (IP, TCP, UDP) is greater th elength of
the packet
# config enable_decode_oversized_alerts
# Same as above, but drop packet if in Inline mode (requires
enable_decode_oversized_alerts)
# config enable_decode_oversized_drops
# Configure IP / TCP checksum mode
config checksum_mode: all
# Configure maximum number of flowbit references. For more information,
see README.flowbits
# config flowbits_size: 64
# Configure ports to ignore
# config ignore_ports: tcp 21 6667:6671 1356
# config ignore_ports: udp 1:17 53
# Configure active response for non inline operation. For more
information, see REAMDE.active
# config response: eth0 attempts 2
# Configure DAQ related options for inline operation. For more
information, see README.daq
#
# config daq: <type>
# config daq_dir: <dir>
# config daq_mode: <mode>
# config daq_var: <var>
#
# <type> ::= pcap | afpacket | dump | nfq | ipq | ipfw
# <mode> ::= read-file | passive | inline
# <var> ::= arbitrary <name>=<value passed to DAQ
# <dir> ::= path as to where to look for DAQ module so's
# Configure specific UID and GID to run snort as after dropping privs. For
more information see snort -h command line options
#
# config set_gid:
# config set_uid:
# Configure default snaplen. Snort defaults to MTU of in use interface.
For more information see README
#
# config snaplen:
#
# Configure default bpf_file to use for filtering what traffic reaches
snort. For more information see snort -h command line options (-F)
#
# config bpf_file:
#
# Configure default log directory for snort to log to. For more
information see snort -h command line options (-l)
#
# config logdir:
###################################################
# Step #3: Configure the base detection engine. For more information, see
README.decode
###################################################
# Configure PCRE match limitations
config pcre_match_limit: 3500
config pcre_match_limit_recursion: 1500
# Configure the detection engine See the Snort Manual, Configuring Snort
- Includes - Config
config detection: search-method ac-split search-optimize max-pattern-len 20
# Configure the event queue. For more information, see README.event_queue
config event_queue: max_queue 8 log 5 order_events content_length
###################################################
## Configure GTP if it is to be used.
## For more information, see README.GTP
####################################################
# config enable_gtp
###################################################
# Per packet and rule latency enforcement
# For more information see README.ppm
###################################################
# Per Packet latency configuration
#config ppm: max-pkt-time 250, \
# fastpath-expensive-packets, \
# pkt-log
# Per Rule latency configuration
#config ppm: max-rule-time 200, \
# threshold 3, \
# suspend-expensive-rules, \
# suspend-timeout 20, \
# rule-log alert
###################################################
# Configure Perf Profiling for debugging
# For more information see README.PerfProfiling
###################################################
#config profile_rules: print all, sort avg_ticks
#config profile_preprocs: print all, sort avg_ticks
###################################################
# Configure protocol aware flushing
# For more information see README.stream5
###################################################
config paf_max: 16000
###################################################
# Step #4: Configure dynamic loaded libraries.
# For more information, see Snort Manual, Configuring Snort - Dynamic Modules
###################################################
# path to dynamic preprocessor libraries
dynamicpreprocessor directory /usr/local/lib/snort_dynamicpreprocessor/
# path to base preprocessor engine
dynamicengine /usr/local/lib/snort_dynamicengine/libsf_engine.so
# path to dynamic rules libraries
dynamicdetection directory /usr/local/lib/snort_dynamicrules
###################################################
# Step #5: Configure preprocessors
# For more information, see the Snort Manual, Configuring Snort -
Preprocessors
###################################################
# GTP Control Channle Preprocessor. For more information, see README.GTP
# preprocessor gtp: ports { 2123 3386 2152 }
# Inline packet normalization. For more information, see README.normalize
# Does nothing in IDS mode
preprocessor normalize_ip4
preprocessor normalize_tcp: ips ecn stream
preprocessor normalize_icmp4
preprocessor normalize_ip6
preprocessor normalize_icmp6
# Target-based IP defragmentation. For more inforation, see README.frag3
preprocessor frag3_global: max_frags 65536
preprocessor frag3_engine: policy windows detect_anomalies overlap_limit
10 min_fragment_length 100 timeout 180
# Target-Based stateful inspection/stream reassembly. For more
inforation, see README.stream5
preprocessor stream5_global: track_tcp yes, \
track_udp yes, \
track_icmp no, \
max_tcp 262144, \
max_udp 131072, \
max_active_responses 2, \
min_response_seconds 5
preprocessor stream5_tcp: policy windows, detect_anomalies, require_3whs
180, \
overlap_limit 10, small_segments 3 bytes 150, timeout 180, \
ports client 21 22 23 25 42 53 70 79 109 110 111 113 119 135 136 137
139 143 \
161 445 513 514 587 593 691 1433 1521 1741 2100 3306 6070 6665
6666 6667 6668 6669 \
7000 8181 32770 32771 32772 32773 32774 32775 32776 32777 32778
32779, \
ports both 80 81 82 83 84 85 86 87 88 89 90 110 311 383 443 465 563
591 593 631 636 901 989 992 993 994 995 1220 1414 1830 2301 2381 2809
3037 3057 3128 3443 3702 4343 4848 5250 6080 6988 7907 7000 7001 7144
7145 7510 7802 7777 7779 \
7801 7900 7901 7902 7903 7904 7905 7906 7908 7909 7910 7911 7912
7913 7914 7915 7916 \
7917 7918 7919 7920 8000 8008 8014 8028 8080 8085 8088 8090 8118
8123 8180 8222 8243 8280 8300 8500 8800 8888 8899 9000 9060 9080
9090 9091 9443 9999 10000 11371 34443 34444 41080 50000 50002
55555
preprocessor stream5_udp: timeout 180
# performance statistics. For more information, see the Snort Manual,
Configuring Snort - Preprocessors - Performance Monitor
# preprocessor perfmonitor: time 300 file /var/snort/snort.stats pktcnt 10000
# HTTP normalization and anomaly detection. For more information, see
README.http_inspect
preprocessor http_inspect: global iis_unicode_map unicode.map 1252
compress_depth 65535 decompress_depth 65535
preprocessor http_inspect_server: server default \
http_methods { GET POST PUT SEARCH MKCOL COPY MOVE LOCK UNLOCK NOTIFY
POLL BCOPY BDELETE BMOVE LINK UNLINK OPTIONS HEAD DELETE TRACE TRACK
CONNECT SOURCE SUBSCRIBE UNSUBSCRIBE PROPFIND PROPPATCH BPROPFIND
BPROPPATCH RPC_CONNECT PROXY_SUCCESS BITS_POST CCM_POST SMS_POST
RPC_IN_DATA RPC_OUT_DATA RPC_ECHO_DATA } \
chunk_length 500000 \
server_flow_depth 0 \
client_flow_depth 0 \
post_depth 65495 \
oversize_dir_length 500 \
max_header_length 750 \
max_headers 100 \
max_spaces 200 \
small_chunk_length { 10 5 } \
ports { 80 81 82 83 84 85 86 87 88 89 90 311 383 591 593 631 901 1220
1414 1741 1830 2301 2381 2809 3037 3057 3128 3443 3702 4343 4848 5250
6080 6988 7000 7001 7144 7145 7510 7777 7779 8000 8008 8014 8028 8080
8085 8088 8090 8118 8123 8180 8181 8222 8243 8280 8300 8500 8800 8888
8899 9000 9060 9080 9090 9091 9443 9999 10000 11371 34443 34444 41080
50000 50002 55555 } \
non_rfc_char { 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 } \
enable_cookie \
extended_response_inspection \
inspect_gzip \
normalize_utf \
unlimited_decompress \
normalize_javascript \
apache_whitespace no \
ascii no \
bare_byte no \
directory no \
double_decode no \
iis_backslash no \
iis_delimiter no \
iis_unicode no \
multi_slash no \
utf_8 no \
u_encode yes \
webroot no
# ONC-RPC normalization and anomaly detection. For more information, see
the Snort Manual, Configuring Snort - Preprocessors - RPC Decode
preprocessor rpc_decode: 111 32770 32771 32772 32773 32774 32775 32776
32777 32778 32779 no_alert_multiple_requests no_alert_large_fragments
no_alert_incomplete
# Back Orifice detection.
preprocessor bo
# FTP / Telnet normalization and anomaly detection. For more information,
see README.ftptelnet
preprocessor ftp_telnet: global inspection_type stateful encrypted_traffic
no check_encrypted
preprocessor ftp_telnet_protocol: telnet \
ayt_attack_thresh 20 \
normalize ports { 23 } \
detect_anomalies
preprocessor ftp_telnet_protocol: ftp server default \
def_max_param_len 100 \
ports { 21 2100 3535 } \
telnet_cmds yes \
ignore_telnet_erase_cmds yes \
ftp_cmds { ABOR ACCT ADAT ALLO APPE AUTH CCC CDUP } \
ftp_cmds { CEL CLNT CMD CONF CWD DELE ENC EPRT } \
ftp_cmds { EPSV ESTA ESTP FEAT HELP LANG LIST LPRT } \
ftp_cmds { LPSV MACB MAIL MDTM MIC MKD MLSD MLST } \
ftp_cmds { MODE NLST NOOP OPTS PASS PASV PBSZ PORT } \
ftp_cmds { PROT PWD QUIT REIN REST RETR RMD RNFR } \
ftp_cmds { RNTO SDUP SITE SIZE SMNT STAT STOR STOU } \
ftp_cmds { STRU SYST TEST TYPE USER XCUP XCRC XCWD } \
ftp_cmds { XMAS XMD5 XMKD XPWD XRCP XRMD XRSQ XSEM } \
ftp_cmds { XSEN XSHA1 XSHA256 } \
alt_max_param_len 0 { ABOR CCC CDUP ESTA FEAT LPSV NOOP PASV PWD QUIT
REIN STOU SYST XCUP XPWD } \
alt_max_param_len 200 { ALLO APPE CMD HELP NLST RETR RNFR STOR STOU
XMKD } \
alt_max_param_len 256 { CWD RNTO } \
alt_max_param_len 400 { PORT } \
alt_max_param_len 512 { SIZE } \
chk_str_fmt { ACCT ADAT ALLO APPE AUTH CEL CLNT CMD } \
chk_str_fmt { CONF CWD DELE ENC EPRT EPSV ESTP HELP } \
chk_str_fmt { LANG LIST LPRT MACB MAIL MDTM MIC MKD } \
chk_str_fmt { MLSD MLST MODE NLST OPTS PASS PBSZ PORT } \
chk_str_fmt { PROT REST RETR RMD RNFR RNTO SDUP SITE } \
chk_str_fmt { SIZE SMNT STAT STOR STRU TEST TYPE USER } \
chk_str_fmt { XCRC XCWD XMAS XMD5 XMKD XRCP XRMD XRSQ } \
chk_str_fmt { XSEM XSEN XSHA1 XSHA256 } \
cmd_validity ALLO < int [ char R int ] > \
cmd_validity EPSV < [ { char 12 | char A char L char L } ] > \
cmd_validity MACB < string > \
cmd_validity MDTM < [ date nnnnnnnnnnnnnn[.n[n[n]]] ] string > \
cmd_validity MODE < char ASBCZ > \
cmd_validity PORT < host_port > \
cmd_validity PROT < char CSEP > \
cmd_validity STRU < char FRPO [ string ] > \
cmd_validity TYPE < { char AE [ char NTC ] | char I | char L [ number
] } >
preprocessor ftp_telnet_protocol: ftp client default \
max_resp_len 256 \
bounce yes \
ignore_telnet_erase_cmds yes \
telnet_cmds yes
# SMTP normalization and anomaly detection. For more information, see
README.SMTP
preprocessor smtp: ports { 25 465 587 691 } \
inspection_type stateful \
b64_decode_depth 0 \
qp_decode_depth 0 \
bitenc_decode_depth 0 \
uu_decode_depth 0 \
log_mailfrom \
log_rcptto \
log_filename \
log_email_hdrs \
normalize cmds \
normalize_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM
ESND ESOM ETRN EVFY } \
normalize_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT
RSET SAML SEND SOML } \
normalize_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT
X-DRCP X-ERCP X-EXCH50 } \
normalize_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN
XLICENSE XQUE XSTA XTRN XUSR } \
max_command_line_len 512 \
max_header_line_len 1000 \
max_response_line_len 512 \
alt_max_command_line_len 260 { MAIL } \
alt_max_command_line_len 300 { RCPT } \
alt_max_command_line_len 500 { HELP HELO ETRN EHLO } \
alt_max_command_line_len 255 { EXPN VRFY ATRN SIZE BDAT DEBUG EMAL
ESAM ESND ESOM EVFY IDENT NOOP RSET } \
alt_max_command_line_len 246 { SEND SAML SOML AUTH TURN ETRN DATA RSET
QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR
XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR } \
valid_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM ESND
ESOM ETRN EVFY } \
valid_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET
SAML SEND SOML } \
valid_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT X-DRCP
X-ERCP X-EXCH50 } \
valid_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE
XQUE XSTA XTRN XUSR } \
xlink2state { enabled }
# Portscan detection. For more information, see README.sfportscan
# preprocessor sfportscan: proto { all } memcap { 10000000 } sense_level
{ low }
# ARP spoof detection. For more information, see the Snort Manual -
Configuring Snort - Preprocessors - ARP Spoof Preprocessor
# preprocessor arpspoof
# preprocessor arpspoof_detect_host: 192.168.40.1 f0:0f:00:f0:0f:00
# SSH anomaly detection. For more information, see README.ssh
preprocessor ssh: server_ports { 22 } \
autodetect \
max_client_bytes 19600 \
max_encrypted_packets 20 \
max_server_version_len 100 \
enable_respoverflow enable_ssh1crc32 \
enable_srvoverflow enable_protomismatch
# SMB / DCE-RPC normalization and anomaly detection. For more
information, see README.dcerpc2
preprocessor dcerpc2: memcap 102400, events [co ]
preprocessor dcerpc2_server: default, policy WinXP, \
detect [smb [139,445], tcp 135, udp 135, rpc-over-http-server 593], \
autodetect [tcp 1025:, udp 1025:, rpc-over-http-server 1025:], \
smb_max_chain 3, smb_invalid_shares ["C$", "D$", "ADMIN$"]
# DNS anomaly detection. For more information, see README.dns
preprocessor dns: ports { 53 } enable_rdata_overflow
# SSL anomaly detection and traffic bypass. For more information, see
README.ssl
preprocessor ssl: ports { 443 465 563 636 989 992 993 994 995 7801 7802
7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914
7915 7916 7917 7918 7919 7920 }, trustservers, noinspect_encrypted
# SDF sensitive data preprocessor. For more information see
README.sensitive_data
preprocessor sensitive_data: alert_threshold 25
# SIP Session Initiation Protocol preprocessor. For more information see
README.sip
preprocessor sip: max_sessions 40000, \
ports { 5060 5061 5600 }, \
methods { invite \
cancel \
ack \
bye \
register \
options \
refer \
subscribe \
update \
join \
info \
message \
notify \
benotify \
do \
qauth \
sprack \
publish \
service \
unsubscribe \
prack }, \
max_uri_len 512, \
max_call_id_len 80, \
max_requestName_len 20, \
max_from_len 256, \
max_to_len 256, \
max_via_len 1024, \
max_contact_len 512, \
max_content_len 2048
# IMAP preprocessor. For more information see README.imap
preprocessor imap: \
ports { 143 } \
b64_decode_depth 0 \
qp_decode_depth 0 \
bitenc_decode_depth 0 \
uu_decode_depth 0
# POP preprocessor. For more information see README.pop
preprocessor pop: \
ports { 110 } \
b64_decode_depth 0 \
qp_decode_depth 0 \
bitenc_decode_depth 0 \
uu_decode_depth 0
# Modbus preprocessor. For more information see README.modbus
preprocessor modbus: ports { 502 }
# DNP3 preprocessor. For more information see README.dnp3
preprocessor dnp3: ports { 20000 } \
memcap 262144 \
check_crc
# Reputation preprocessor. For more information see README.reputation
preprocessor reputation: \
memcap 500, \
priority whitelist, \
nested_ip inner, \
whitelist $WHITE_LIST_PATH/white_list.rules, \
blacklist $BLACK_LIST_PATH/black_list.rules
###################################################
# Step #6: Configure output plugins
# For more information, see Snort Manual, Configuring Snort - Output Modules
###################################################
# unified2
# Recommended for most installs
output unified2: filename merged.log, limit 128, nostamp,
mpls_event_types, vlan_event_types
# Additional configuration for specific types of installs
# output alert_unified2: filename snort.alert, limit 128, nostamp
# output log_unified2: filename snort.log, limit 128, nostamp
# syslog
# output alert_syslog: LOG_AUTH LOG_ALERT
# pcap
# #output log_tcpdump: tcpdump.log
# metadata reference data. do not modify these lines
include classification.config
include reference.config
Had to chop due to size restrictions.
My complete snort.conf here ->
http://www.bpaste.net/show/K4IoLi86w5fdsoRweQ0m/
My complete startup here -> http://www.bpaste.net/show/uOVVEgNWHFYTwZNmBezI/