Skip to content

Instantly share code, notes, and snippets.

@drucko
drucko / gist:4945238
Last active December 13, 2015 17:08 — forked from chrismatthieu/gist:964754
Sip registrarserver with node.js
// Run Redis - cd redis-2.2.4 and run src/redis-server
var sip = require('sip');
var sys = require('sys');
var redis = require('redis');
var tropoapi = require('tropo-webapi');
//Trim leading and trailing whitespace from string values.
function trim(str) {
return str.replace(/^\s+|\s+$/g, '');
#!/bin/bash
#
# template script for generating CentOS container for LXC
#
#
# lxc: linux Container library
# Authors:
<!DOCTYPE HTML>
<!--
/*
* Remote File Copy Demo 1.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
@drucko
drucko / bg_typoscript.ts
Created April 4, 2013 17:44
Background-Images via TypoScript With IMG_RESOURCE you can manipulate an IMAGE via TYPO3 without outputting the whole img-Tag. IMG_RESOURCE creates an Image in typotemp (f.e. typo3temp/pics/134e7c7dd2.jpg). So you can use it then as an background-image.
page.90 = IMG_RESOURCE
page.90.file = fileadmin/Dog.jpg
page.90.file.width = 100
page.90.file.height = 100
page.90.stdWrap.wrap (
<div style="background-image:url(|); width:100px; height:100px;">Headline</div>
)
This is the result:
<?php
// Example of how to log into Google API with ClientLogin, good to use when you're not making a webapp.
// code taken and minimally updated from http://kovshenin.com/2009/10/google-docs-api-client-login-with-php-and-curl-1494/
// Construct an HTTP POST request
$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
$clientlogin_post = array(
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => "[email protected]",

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
<?php
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth ) {
//In a child UL, add the 'dropdown-menu' class
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
def extract_form_fields(self, soup):
"Turn a BeautifulSoup form in to a dict of fields and default values"
fields = {}
for input in soup.findAll('input'):
# ignore submit/image with no name attribute
if input['type'] in ('submit', 'image') and not input.has_key('name'):
continue
# single element nome/value fields
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'):
upstream php-fpm {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name www.example.com;
rewrite ^ http://example.com$request_uri?;
}
export version=1.5.3
if [ "$#" -gt 0 ] ; then
export version="$1"
fi
echo "Installing Dropbox SDK version $version"
wget https://www.dropbox.com/static/developers/dropbox-java-sdk-$version.zip
unzip dropbox-java-sdk*
cd dropbox-java-sdk*