Skip to content

Instantly share code, notes, and snippets.

@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@ibeex
ibeex / auth.py
Created October 14, 2011 20:04
Python LDAP (ActiveDirectory) authentication
import ldap
def check_credentials(username, password):
"""Verifies credentials for username and password.
Returns None on success or a string describing the error on failure
# Adapt to your needs
"""
LDAP_SERVER = 'ldap://xxx'
# fully qualified AD user name
LDAP_USERNAME = '%s@xxx.xx' % username
@FiloSottile
FiloSottile / La Coscienza di un Hacker
Last active April 2, 2023 23:46
Traduzione in italiano dell'Hacker Manifesto
Questa è una traduzione in italiano del celebre Hacker Manifesto. Tutte quelle
esistenti contengono grossolani errori, perlopiù dovuti ad una carente
comprensione della materia e del periodo, o in ogni caso sono poco fedeli al
contenuto e allo spirito dell'originale. Mi auguro che questa mia traduzione non
soffra degli stessi problemi. Sail strong.
-- FiloSottile
****
Da: Phrack, Volume Uno, Issue 7, Phile 3 of 10
@XueshiQiao
XueshiQiao / gource.sh
Last active November 10, 2019 15:56 — forked from cgoldberg/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@danharper
danharper / background.js
Last active May 22, 2024 11:09
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@denilsonsa
denilsonsa / Python Virtual Environments on Debian and Ubuntu.md
Last active December 1, 2016 06:25
Python Virtual Environments on Debian and Ubuntu

pyvenv-3.3 (Ubuntu 13.10, also Debian)

Symptoms

pyvenv-3.3 venvdir
venvdir/bin/python -c 'import sys; print(sys.path)'
# This should print the venvdir in sys.path.

But in buggy Ubuntu/Debian, it doesn't.

@edigiacomo
edigiacomo / leaflet-arpa-wsf-wms.html
Last active August 29, 2015 14:10
This example show how to load some data from ARPA Emilia-Romagna WFS and WMS using Leaflet, OpenLayers (as a GML parser) and jQuery.
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js"></script>
<script>
var map = null;
var macroarea = null;
@Zulko
Zulko / zombie_france.py
Last active May 24, 2024 21:54
Zombie pandemic simulation in France
"""
Model of a Zombie outbreak in France, starting in Grenoble
This is a rewrite from this blog post by Max Berrgren:
http://maxberggren.github.io/2014/11/27/model-of-a-zombie-outbreak/
with a different country, a slightly different model, and different
libraries. The map of population density is taken from Wikimedia Commons
@edigiacomo
edigiacomo / ckan-datastore-upsert.py
Last active September 13, 2021 11:36
Simple example of upserting records in a CKAN Datastore
import requests # http://docs.python-requests.org/en/latest/
import json
def upsert_records(records, ckan_url, resource_id, ckan_api_key=None):
"""Send a list of records to CKAN Datastore and return a requests.Response
object (see http://docs.python-requests.org/en/latest/api/#requests.Response).
Example:
url = "http://mysite.org/ckan"
resource_id = "7d33cafe-0118-4b9a-8d8d-e82d1935e2ea"
@jeff-1amstudios
jeff-1amstudios / C64-sprite-animation.asm
Last active December 2, 2021 14:43
C64 sprite animation routine
FRAME_COUNT = 10 ; constant for the nbr of sprite frames you have
.frame_counter !byte .FRAME_COUNT ; variable to keep track of how far through the animation we are
SPRITE_INITIAL_DATA_POINTER = 128 ; sprite data will be read by VIC-II at 128*64 ($2000)
on_screen_refresh
dec .frame_counter ; frame_counter variable -= 1
bne .increment_sprite_pointer ; if frame_counter > 0, goto .increment_sprite_pointer...
lda #SPRITE_INITIAL_DATA_POINTER ; ... otherwise, we should reset to the start of the animation
sta $07f8 ; reset the sprite pointer to start of sprite data
ldx #FRAME_COUNT