Skip to content

Instantly share code, notes, and snippets.

View juntalis's full-sized avatar

Charles Grunwald juntalis

View GitHub Profile
@sj26
sj26 / phpserialize.py
Created February 2, 2010 09:53
Python port of PHP serialize() and unserialize()
#!/usr/bin/python -u
"""
Python port of PHP serialize() and unserialize()
by Samuel Cochran <[email protected]>
I couldn't find a nice, fairly efficient implementation of serialize/unserialize for Python... so I wrote one. I didn't use str().partition because I wanted Python <2.5 compatibility.
TODO: Performance review. There's an awful lot of string copying. >.>
@Arbow
Arbow / Thread.php
Created May 20, 2011 03:56
PHP Process Pool With Executor
<?php
//Found on http://www.alternateinterior.com/2007/05/multi-threading-strategies-in-php.html
//Modified by http://www.php-code.net
//Modified: add executor
class Thread {
var $pref ; // process reference
var $pipes; // stdio
var $buffer; // output buffer
var $output;
var $error;
@madhur
madhur / approval.js
Created January 9, 2012 18:22
SharePoint 2010 Approval workflow with dynamic approvers
<div id='intake'>
<img src="/sites/nishantverma/GBSRequest/SiteAssets/loading.gif" />
<br/>
Submitting your request for approval
</div>
<script type="text/javascript" src="/sites/nishantverma/GBSRequest/SiteAssets/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/sites/nishantverma/GBSRequest/SiteAssets/jquery.SPServices-0.7.0.min.js"></script>
@malkia
malkia / platforms.txt
Created January 21, 2012 05:07
Platforms: Hosts and Targets, Tools and SDKs
Terminology
===========
1. Platform - The combination of Operating System, Kernel, Tools and Runtime, and/or specific hardware device.
2. Desktop Platform - Typical computer with mouse & keyboard
3. Mobile Platform - Cell Phone, Touch Pad or other similar portable device
4. Host Platform - The platform on which the product is built.
5. Target Platform - The platform on which the product runs.
6. Target Runtime Library - The main "C" library for which the product is compiled.
@Zoxc
Zoxc / injector.cpp
Created June 10, 2012 17:40
DLL Injector for x86/x64
#pragma once
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <tchar.h>
#include <shellapi.h>
#include <string>
#include <sstream>
#include <functional>
@sudar
sudar / url-encode.c
Created August 20, 2012 14:59
URLEncoding in C
int c;
char *hex = "0123456789abcdef";
while( (c = getchar()) != EOF ){
if( ('a' <= c && c <= 'z')
|| ('A' <= c && c <= 'Z')
|| ('0' <= c && c <= '9') ){
putchar(c);
} else {
putchar('%');
@Lee-R
Lee-R / lithash.cpp
Created October 5, 2012 13:27
C++11 compile-time hash of literal strings.
#include <cstdint>
namespace detail
{
// FNV-1a 32bit hashing algorithm.
constexpr std::uint32_t fnv1a_32(char const* s, std::size_t count)
{
return ((count ? fnv1a_32(s, count - 1) : 2166136261u) ^ s[count]) * 16777619u;
}
} // namespace detail
@dspezia
dspezia / example.c
Created November 26, 2012 18:26
Example of Redis zset polling daemon
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/ae.h"
#include "sha1.h"
@clemensg
clemensg / curl_multi_test.c
Last active June 28, 2023 06:51
libcurl multi interface example
/* curl_multi_test.c
Clemens Gruber, 2013
<[email protected]>
Code description:
Requests 4 Web pages via the CURL multi interface
and checks if the HTTP status code is 200.
Update: Fixed! The check for !numfds was the problem.
@klovadis
klovadis / gist:5170446
Created March 15, 2013 14:59
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v