Skip to content

Instantly share code, notes, and snippets.

View bonnebulle's full-sized avatar
🎯
Focusing

vincent_b bonnebulle

🎯
Focusing
View GitHub Profile
@matiasfha
matiasfha / client.html
Created June 6, 2011 16:04
nodejs + thrift +socket.io for image streaming
<script src="jquery-1.6.1.min.js"></script>
<script src="socket.io/socket.io.js"></script>
<script>
var socket = new io.Socket(null,{port:8080});
socket.connect();
socket.on('message',function(obj){
switch(obj.tipo){
case 'imagen':
img = document.getElementById('stream');
img.src="";
@rogerlsmith
rogerlsmith / ColorTime.php
Created November 4, 2011 14:57
PHP Code that will convert time to RGB color using HSV
function getColor()
{
$tod = localtime();
$now = $tod[1] + ($tod[2] * 60.0);
$now = $now * (1.0 / (24.0 * 60.0));
$rgb_array = HSV_TO_RGB($now, 0.5, 0.5);
$rgb = dechex($rgb_array['R']) . dechex($rgb_array['G']) . dechex($rgb_array['B']);
return ($rgb);
}
@mikeplate
mikeplate / setup-vsftpd.sh
Created November 15, 2011 17:12
Set up vsftpd for multiple users
#!/bin/bash
#
# This script is used to set up vsftpd for multiple virtual users with predefined passwords
# fetched from a text file. The vsftpd configuration file that is outputted enforces
# FTP Explicit TLS for all client connections.
#
# The text file with predefined users and passwords must have the following format:
# <username>:<password>
#
userfile=users.txt
@yellowled
yellowled / ffmpeg-html5
Created December 6, 2011 19:39
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. Will probably convert this to a bash script later, but for the time being, here's some examples. Not sure there have actually sensible dimensions and bitrates for web video.
# webm
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm
# mp4
ffmpeg -i IN -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -vpre slow -f mp4 -crf 22 -s 640x360 OUT.mp4
# ogg (if you want to support older Firefox)
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
@puppybits
puppybits / image64.sh
Created January 5, 2012 14:18
Create data URI image from Terminal command
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
@iwek
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@ttscoff
ttscoff / lazyfootnotes.rb
Created October 29, 2013 17:32
Lazy footnotes for Markdown, based on TidBits lazy link style
#!/usr/bin/env ruby
# encoding: utf-8
=begin
http://marked2app.com
Marked 2 preprocessor - "Lazy" footnotes.
Allows use of `[^]` or `†` footnote references
where the next [^]: or †: note defines the text of the footnote.
@spotco
spotco / gist:8265971
Created January 5, 2014 08:50
bash convert files to mp3 sox bash
for f in *.m4a; do sox "$f" -C 56 "${f%.m4a}.mp3"; done
@chrisveness
chrisveness / utf8-regex.js
Last active May 25, 2023 01:53
Utf8 string encode/decode using regular expressions
/**
* Encodes multi-byte Unicode string into utf-8 multiple single-byte characters
* (BMP / basic multilingual plane only).
*
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars.
*
* Can be achieved in JavaScript by unescape(encodeURIComponent(str)),
* but this approach may be useful in other languages.
*
* @param {string} unicodeString - Unicode string to be encoded as UTF-8.
@michaelmob
michaelmob / StartPage Bangs
Last active November 4, 2023 11:18
Adds !s to StartPage, like DDG
// ==UserScript==
// @name StartPage Bangs
// @namespace http://tarkus.co/
// @version 0.1
// @description Adds !s to StartPage, like DDG
// @match https://startpage.com/*
// @run-at document-start
// ==/UserScript==
// Bangs