Skip to content

Instantly share code, notes, and snippets.

@cdario
cdario / readFile-response with node.js
Last active December 20, 2015 08:49
Node.js: Reads a file in the server and writes its contents to the response. Nested non-blocking calls
var http = require('http');
var fs = require('fs');
http.createServer(function(request, response) {
response.writeHead(200); // 1.
var callback = function(err, contents){
response.write(contents); // 3.
response.end(); // 4.
}
@cdario
cdario / readFile-response with Content-Type in node.js
Created July 29, 2013 08:33
Reads a file from the server, and write its contents (HTML). Non-blocking calls.
var http = require('http');
var fs = require('fs');
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/html'});
fs.readFile('index.html', function(err, contents) {
response.write(contents);
response.end();
});
@cdario
cdario / git-create-push
Created July 30, 2013 10:28
Create a repo in github via and push it via command line
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin [email protected]:USER/REPO.git
git push origin master
package demo1
import com.espertech.esper.client.EventBean
import com.espertech.esper.client.EPAdministrator
import com.espertech.esper.client.UpdateListener
import com.espertech.esper.client.EPListenable
import com.espertech.esper.client.EPServiceProvider
object EsperUtil {

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@cdario
cdario / git: find a string in file all branches
Last active August 29, 2015 14:05
find something in a file in all branches in git
git log -p -S 'method-class-variable-name-to-find' --all -- .\Namespace\FileToLookInto.php
git show a4283169fb5c4335ff916376d5dfc65c34b16f27 //commit number from previous command
@cdario
cdario / camunda_on_debian
Last active August 29, 2015 14:10
camunda_on_debian
#!/bin/bash
echo "Installing Java 7"
#install java7 pre-requisite
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" > /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get --assume-yes update
# avoid agreement pop up
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
#!/bin/bash
#Inspired by http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/
#Copy a file or directory out of a git repository, preserving history!
#Creates DESTINATIONPATH with patches that can be applied with git am
#e.g.
#0001-Add-new-theme-Gum.patch
#0002-Add-syntax-highlighting-for-Gum-theme.patch
#0003-Gum-Fix-tag-URLs-not-being-slugified-and-therefore-b.patch
#0004-Gum-Add-Disqus-support.patch
#0005-Gum-Use-article-title-as-the-title-of-the-generated-.patch
@cdario
cdario / copy before closing html tag
Last active August 29, 2015 14:14
smooth scrolling javascript
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".contactLink").click(function(){
if ($("#contactForm").is(":hidden")){
$("#contactForm").slideDown("slow");
}
else{
$("#contactForm").slideUp("slow");
}