Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
code for food

Gianluca Pacchiella gipi

😎
code for food
View GitHub Profile
@gipi
gipi / gist:1301059
Created Oct 20, 2011
Check HTML5 storage support
View gist:1301059
// 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 Oct 21, 2011
Creating a home page to download an In House ad hoc iphone application
View Manifest.plist
<?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 Oct 21, 2011
Add screen resolution supporto to android application.
View gist:1304734
<manifest
...
>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
/>
@gipi
gipi / bad.py
Created Oct 24, 2011
Python functions' default value is evaluated at function definition time.
View bad.py
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 Oct 26, 2011
Simple example of facebook posting in Android
View gist:1316346
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 Sep 27, 2015
Pretty print #json with #python #oneliner
View gist:1321981
echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
@gipi
gipi / local_settings.py
Created Oct 31, 2011
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
View local_settings.py
# 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 Sep 7, 2018
Create a #gstreamer pipeline to use with #skype
View gist:1330214
#!/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 Sep 27, 2015
Domain dependent web root directory in #nginx. Need version 0.7.40
View gist:1330564
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;