Skip to content

Instantly share code, notes, and snippets.

@saga
saga / gist:4186392
Created December 2, 2012 01:23
appfog youtube python
#!/usr/bin/env python
import simplejson
import logging
import random
import re
import datetime
import string
import time
import sys
@saga
saga / gist:4137880
Created November 24, 2012 00:54
appfog get youtube
#!/usr/bin/env python
import simplejson
import logging
import random
import re
import datetime
import string
import time
import sys
import urllib
@saga
saga / a
Created November 15, 2012 13:06
aaa
https://openshift.redhat.com/community/blogs/enabling-python-27-on-a-paas-with-the-openshift-diy-app-type
https://openshift.redhat.com/community/blogs/a-paas-that-runs-anything-http-getting-started-with-diy-applications-on-openshift
Enabling Python 2.7 on a PaaS with the OpenShift DIY App Type
Thursday, May 17, 2012
by Evan Hazlett
Developer - Hacker
Preface
I have been using OpenShift for a few months now and have to say that I still love it. I've sampled most of the other PaaS solutions and feel most comfortable with OpenShift. One of the features I enjoy most in the service is the "do-it-yourself" application. With this, you can run just about anything in a "minimal-hassle", scalable environment.
from flask import Flask
import platform
from flask import Request, Response
from werkzeug.routing import BaseConverter
import time
import sys
import json
import urllib2
#!/usr/bin/env python
import time
import sys
import os
import json
from flask import Flask, Request, Response
from werkzeug.routing import BaseConverter
import urllib2
@saga
saga / gist:3792277
Created September 27, 2012 05:18
outputdebugstring C++
TCHAR bufferWill[512];
_stprintf(bufferWill, TEXT(" ## [%s] BEGIN ##L%d\n"), __FUNCTION__,
,__LINE__);
::OutputDebugString(bufferWill);
// OLE2W(message)
@saga
saga / gist:3791807
Created September 27, 2012 02:21
outputdebugstring python
# Original code by Dan Brotherston
import sys
import mmap
import struct
import win32event
import thread
import time
def OutputDebug(threadName, delay):
buffer_ready = win32event.CreateEvent(None, 0, 0, "DBWIN_BUFFER_READY")
@saga
saga / Scheduler.lua
Created September 7, 2012 03:34 — forked from Deco/coroutine_scheduler.lua
Lua Coroutine Scheduler
pcall(require,"socket")
Scheduler = setmetatable({}, {
__call = function(class)
return setmetatable({
threads = {},
}, class)
end
})
Scheduler.__index = Scheduler
@saga
saga / gist:3340225
Created August 13, 2012 12:31
Lua coroutine download files
require "socket"
function download (host, file, port)
port = port or 80
print (host, file, port)
local connectStatus, myConnection = pcall (socket.connect,host,port)
if (connectStatus) then
myConnection:settimeout(0.01) -- do not block you can play with this value
local count = 0 -- counts number of bytes read
-- May be easier to do this LuaSocket's HTTP functions
-- cothread.lua
local co = coroutine
local error = error
local setmetatable = setmetatable
local unpack = unpack
local assert = assert
local type = type
local pairs = pairs