Skip to content

Instantly share code, notes, and snippets.

View vidakovic's full-sized avatar
🎯
Focusing

Aleksandar Vidakovic vidakovic

🎯
Focusing
View GitHub Profile
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.HashMap;
import java.util.Map;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.channel.*;
import static org.jboss.netty.channel.Channels.pipeline;
import org.jboss.netty.handler.codec.http.*;
@xlson
xlson / mp4it
Created October 7, 2010 14:29
Groovy script that uses ffmpeg to convert an avi file into a mp4 for viewing on an iPhone or iPod
#!/usr/bin/env groovy
// Validating arguments
assert args.size() == 1 : "mp4it takes 1 argument: the path to the file to be conerted into mp4"
assert new File(args[0]).exists() : "The file you specified could not be found."
def videoFilePath = args[0]
def outputFilePath = videoFilePath.replaceAll(/\.avi$/, '.mp4')
assert !new File(outputFilePath).exists()
@vpalos
vpalos / options.js
Created May 20, 2011 07:29
JS: CLI argument parser.
/** Command-line options parser (http://valeriu.palos.ro/1026/).
Copyright 2011 Valeriu Paloş ([email protected]). All rights reserved.
Released as Public Domain.
Expects the "schema" array with options definitions and produces the
"options" object and the "arguments" array, which will contain all
non-option arguments encountered (including the script name and such).
Syntax:
[«short», «long», «attributes», «brief», «callback»]
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
@mourner
mourner / TileLayer.Common.js
Created February 11, 2012 23:11
Leaflet shortcuts for common tile providers
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {
@levidehaan
levidehaan / .zshrc
Created February 27, 2012 18:07
my oh-my-zsh config
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="xiong-chiamiov-plus"
plugins=(git command-not-found debian git-flow history-substring-search kate node npm python ssh-agent vi-mode)
source $ZSH/oh-my-zsh.sh
export PATH=/home/th3m4d0n3/.nvm/v0.6.11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/builds
@mumrah
mumrah / kafka-rest.md
Created August 3, 2012 14:35
Kafka REST proposal

REST interface for Kafka

Taking inspiration from the projects page...

I think it would really useful and pretty simple to add a REST interface to Kafka. I could see two possible routes (not mutually exclusive): using HTTP as a dumb transport layer, and using it with different media types for application-friendly consumption of messages (JSON, XML, etc). The dumb transport would be useful for languages without first-class clients, and the content-type extension would be useful for writing web apps that are Kafka-enabled.

HTTP as a transport

Consuming data

@abourget
abourget / directives.js
Created August 8, 2012 20:24
Hammer.js integration with AngularJS
/**
* Inspired by AngularJS' implementation of "click dblclick mousedown..."
*
* This ties in the Hammer events to attributes like:
*
* hm-tap="add_something()"
* hm-swipe="remove_something()"
*
* and also has support for Hammer options with:
*
@amoilanen
amoilanen / webcrawler.js
Last active March 24, 2022 03:14
Simple PhantomJS-based web crawler library
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};
};
@benjchristensen
benjchristensen / VideoExample.groovy
Last active February 14, 2016 11:20
Example of using RxJava in Groovy to compose nested asynchronous calls.
package rx.examples.groovy;
import rx.observables.Observable
import rx.observables.Observer;
import rx.observables.Subscription;
import rx.util.functions.Func1;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;