Skip to content

Instantly share code, notes, and snippets.

View gipi's full-sized avatar
😎
code for food

Gianluca Pacchiella gipi

😎
code for food
View GitHub Profile
@gipi
gipi / gist:1301059
Created October 20, 2011 12:51
Check HTML5 storage support
// via dive into html5
function supports_local_storage() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch(e){
return false;
}
}
@gipi
gipi / Manifest.plist
Created October 21, 2011 13:09
Creating a home page to download an In House ad hoc iphone application
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
@gipi
gipi / gist:1304734
Created October 21, 2011 19:39
Add screen resolution supporto to android application.
<manifest
...
>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
/>
@gipi
gipi / bad.py
Created October 24, 2011 12:18
Python functions' default value is evaluated at function definition time.
def bad_append(new_item, a_list=[]):
"""
>>> print bad_append('one')
['one']
>>> print bad_append('two')
['one', 'two']
"""
a_list.append(new_item)
return a_list
@gipi
gipi / gist:1316346
Created October 26, 2011 13:29
Simple example of facebook posting in Android
import com.facebook.android.*;
import com.facebook.android.Facebook.*;
public class MyActivity extends Activity {
private Facebook mFacebook = new Facebook("0123456", R.drawable.ic_fb);
public void callFacebook(final Activity activity, final String title, final String caption, final String picURL) {
android.util.Log.i("FB", "callFacebook");
mFacebook.authorize(activity, new DialogListener() {
@gipi
gipi / gist:1321981
Last active September 27, 2015 19:47
Pretty print #json with #python #oneliner
echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
@gipi
gipi / local_settings.py
Created October 31, 2011 08:54
Configure a Django project to use a specific database to use when run tests if we can't create databases with the user credential defined in the 'default' one
# Since we need a syncdb on all the databases, before the tests can be
# runned successfully we need to execute
#
# $ python manage.py syncdb
# $ python manage.py syncdb --database=test
#
# otherwise will be errors like
#
# 'django.db.utils.DatabaseError: no such table: django_site'
@gipi
gipi / gist:1330214
Last active September 7, 2018 22:41
Create a #gstreamer pipeline to use with #skype
#!/bin/sh
# to use with v4l2loopback module
gst-launch -v videotestsrc ! "video/x-raw-yuv,width=640,height=480,framerate=30/1,format=(fourcc)UYVY" ! v4l2sink device=/dev/video1
@gipi
gipi / gist:1330564
Last active September 27, 2015 20:58
Domain dependent web root directory in #nginx. Need version 0.7.40
server {
listen 80; ## listen for ipv4
# if we have www.miao.bau then the variables defined from
# the regex are $1 = www and $2 = miao.bau
server_name localhost ~^(www\.)?(.+)$;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/$2;