Skip to content

Instantly share code, notes, and snippets.

View geek-at's full-sized avatar
🐢

Christian Haschek geek-at

🐢
View GitHub Profile
<?php
//
//
//// Decide how many children to use.
$children = 10;
// Load Predis. If using PHP 5.2, call new Predis_Client() instead.
$predis = new Redis();
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
for ($i = 0; $i < 100; $i++) {
$start = microtime(true);
for ($j = 0; $j < 10000; $j++) {
$key = sprintf("key:%05d", $j);
/* GET or SET */
@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
@zekizeki
zekizeki / mqttpublish.php
Last active December 9, 2020 23:33
Simple pure MQTT publish client written in PHP
<?php
/**
*
* The MQTTClient class allows you to connect to an MQTT message broker and publish messages
* @author rob.s.smart@gmail.com
*
* Example use
* $client = new MQTTClient("robphptest","realtime.ngi.ibm.com",1883);
* $client->connect();
@JeffPaine
JeffPaine / make_github_issue.py
Created July 19, 2012 17:24
Make an issue on github using API V3 and Python
import json
import requests
# Authentication for user filing issue (must have read/write access to
# repository to add issue to)
USERNAME = 'CHANGEME'
PASSWORD = 'CHANGEME'
# The repository to add this issue to
REPO_OWNER = 'CHANGEME'
@meglio
meglio / aes256cbc.php
Created October 27, 2012 17:12
Enc/Dec AES 256 CBC, with data consistency validation
private static function iv()
{
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
return mcrypt_create_iv($iv_size, MCRYPT_RAND);
}
static function encrypt($str, $key32)
{
# Prepend 4-chars data hash to the data itself for validation after decryption
$str = substr(md5($str), 0, 4).$str;
@StuPig
StuPig / handlebar_partials.html
Created December 16, 2012 07:15
handlebars partials demo
<!DOCTYPE html>
<html>
<head>
<title>Handlebars Partials Example</title>
</head>
<body>
<h1>Handlebars Partials Example!</h1>
<div id="list">
</div>
@willurd
willurd / web-servers.md
Last active July 22, 2024 15:25
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mullnerz
mullnerz / archive-website.md
Last active May 14, 2024 20:06
Archiving a website with wget

The command I use to archive a single website

wget -mpck --html-extension --user-agent="" -e robots=off --wait 1 -P . www.foo.com

Explanation of the parameters used

  • -m (Mirror) Turns on mirror-friendly settings like infinite recursion depth, timestamps, etc.