Skip to content

Instantly share code, notes, and snippets.

View daleffe's full-sized avatar
💭
I may be slow to respond.

Guilherme Roberge Daleffe daleffe

💭
I may be slow to respond.
View GitHub Profile
@j4mie
j4mie / normalise.py
Created August 30, 2010 12:44
Normalise (normalize) unicode data in Python to remove umlauts, accents etc.
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal
<?php
// The URL where the test-auth.php script resides.
define("POST_DATA_TO_URL", "http://someurl/my-script.php");
// Function to send value to my-script.php script via cURL with digest authentication.
function submitValue($myValue) {
$ch = curl_init(POST_DATA_TO_URL);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, "admin:mypass");
@smasty
smasty / 01.php
Created June 6, 2011 22:33
10 PHP One Liners to Impress Your Friends - http://smasty.net/blog/10-php-oneliners
<? foreach(range(1, 10) as $i) echo $i * 2 . " ";
@farhadi
farhadi / rc4.js
Created March 24, 2012 17:09
RC4 encryption in javascript and php
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
@misaelnieto
misaelnieto / live-mjpeg-stream.py
Last active June 26, 2024 10:08
Streaming MJPEG over HTTP with gstreamr and python - WSGI version
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Updates:
# - 2024-04-24: Apply suggestions from @Pin80
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
#updated command line
#gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! video/x-raw, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! #tcpclientsink port=9999
from multiprocessing import Queue
@misaelnieto
misaelnieto / live-mjpeg-stream.py
Created April 17, 2012 23:18
Streaming MJPEG over HTTP with gstreamr and python - WSGI version, No need for external process
#!/usr/bin/env python
#Works nicely, but wsgiserver times out aftr some time
#Python imports
import sys
import signal
from wsgiref.simple_server import make_server
@shamil
shamil / howto_deb_repackage.txt
Created July 19, 2012 03:29
Howto repackage deb packages
Use folowing steps to repackage dep package:
1: Extract deb package
# dpkg-deb -x <package.deb> <dir>
2: Extract control-information from a package
# dpkg-deb -e <package.deb> <dir/DEBIAN>
3. After completed to make changes to the package, repack the deb
# dpkg-deb -b <dir> <new-package.deb>
@rollsroyc3
rollsroyc3 / gist:6869880
Last active November 7, 2023 20:06
HTTP Digest Authentication
//HTTP Digest Authentication
//---------------------------
//Step 1: Send request to server with no credentials
//Step 2: Get 410 response with Www-Authenticate header containing Digest variables and do magic
//Step 3: Send back request with new magical header
//Step 4: Receive original request data
==================================================
@nairteashop
nairteashop / mjpeg-server.py
Created November 11, 2013 04:37
A simple Motion JPEG server in python for creating "virtual cameras" from video sequences.
#!/usr/bin/python
#
# A simple Motion JPEG server in python for creating "virtual cameras" from video sequences.
#
# The cameras will support MJPEG streaming over HTTP. The MJPEG streams are formed from static JPEG images.
# If you wish to stream a video file, use a tool like VirtualDub to break the video into a sequence of JPEGs.
#
# The list of cameras should be defined as a series of entries in a file named 'mjpeg-server.conf', with
# each entry having the following format:
@ageekymonk
ageekymonk / usb-autoinstall.sh
Created September 5, 2014 03:45
Custom USB Debian Installer with preseed
disk=$1
iso=$2
primary="$disk"1
if [ -z $disk ]
then
echo "Specify a correct drive name"
exit
fi
if [ -z $iso ]