This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Input: URI -- something like content://com.example.app.provider/table2/dataset1 | |
Output: PATH -- something like /sdcard/DCIM/123242-image.jpg | |
*/ | |
public String convertMediaUriToPath(Uri uri) { | |
String [] proj={MediaStore.Images.Media.DATA}; | |
Cursor cursor = getContentResolver().query(uri, proj, null, null, null); | |
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |
cursor.moveToFirst(); | |
String path = cursor.getString(column_index); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userChoice = prompt("Do you choose rock, paper or scissors?"); | |
var computerChoice = Math.random(); | |
if (computerChoice <= (1/3)) { | |
computerChoice = "rock"; | |
} else if(computerChoice <= (2/3)) { | |
computerChoice = "paper"; | |
} else { | |
computerChoice = "scissors"; | |
} | |
compare(userChoice,computerChoice); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cat /var/log/apache2/access_log | awk '{print $1}' > ips.txt | |
uniq ips.txt > uniqips.txt | |
IPS=`cat uniqips.txt` | |
for i in $IPS | |
do | |
echo "$i,`geoiplookup $i | cut -d "," -f2 | sed -e 's/^[\t]//'`" >> ipinfo.csv | |
done |
NewerOlder