This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor | |
from twisted.web.websocket import WebSocketHandler, WebSocketResource | |
from twisted.web.server import Site | |
from twisted.web.static import File | |
class Echohandler(WebSocketHandler): | |
def frameReceived(self, frame): | |
self.sendFrame(frame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
var myWebSocket = new WebSocket("ws://127.0.0.1:8080/ws/echo"); | |
myWebSocket.onopen = function(evt) { | |
alert("Connection open ..."); | |
}; | |
myWebSocket.onmessage = function(evt) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Dynamically resize images | |
function thumb_create($file, $width , $height ) { | |
try | |
{ | |
/*** the image file ***/ | |
$image = $file; | |
/*** a new imagick object ***/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Find the full url to the site we are at | |
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; | |
$address = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
$currentFile = $_SERVER["SCRIPT_NAME"]; | |
$parts = Explode('/', $currentFile); | |
$currentFile = $parts[count($parts) - 1]; | |
$site_path = str_replace($currentFile,'',$address); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this way is best if you want to stay up to date | |
# or submit patches to node or npm | |
mkdir ~/local | |
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.profile | |
# could also fork, and then clone your own fork instead of ry's | |
git clone git://github.com/ry/node.git | |
cd node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is a little example of how to make a PUT request (see http://microformats.org/wiki/rest/urls ) | |
#To a API written with tastypie (https://github.com/toastdriven/django-tastypie ) | |
# import the standard JSON parser | |
import json | |
# import the REST library (from http://code.google.com/p/python-rest-client/) | |
from restful_lib import Connection | |
#site url | |
base_url = "http://IP/api/v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# This work is licensed under the Creative Commons Attribution 3.0 United | |
# States License. To view a copy of this license, visit | |
# http://creativecommons.org/licenses/by/3.0/us/ or send a letter to Creative | |
# Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. | |
# from http://oranlooney.com/make-css-sprites-python-image-library/ | |
# Orignial Author Oran Looney <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Checkbox</title> | |
<style> | |
input[type=checkbox] { | |
display:none; | |
} | |
input[type=checkbox] + label | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION="0.1" | |
#Set the URL for the API requests | |
plugin_url=http://127.0.0.1/rundb/api/v1/results/${RUNINFO__PK}/plugin/ | |
#Set the HTTP Headers | |
api_header="Content-Type: application/json;Accept: application/json" |
OlderNewer