Skip to content

Instantly share code, notes, and snippets.

@oscarrenalias
oscarrenalias / pom.xml
Created October 4, 2011 17:33 — forked from lobster1234/pom.xml
Maven pom.xml compatible with Scala 2.9.1 with updated dependency versions. This is needed because the archetype:generate for scala-archetype-simple will be 2.8 and the tests will fail with 2.9.1.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.manish</groupId>
<artifactId>scala-simple</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
@oscarrenalias
oscarrenalias / nodeproxy.js
Created October 29, 2011 11:43
A very simple Node HTTP proxy that proxies requests to the server given in the GET or POST URL. Heavily inspired by http://www.catonmat.net/http-proxy-in-nodejs/.
//
// How to use:
//
// 1. Start node:
// node nodeproxy.js
// 2. Send a URL like this:
// http://localhost:8080/http://www.google.com
//
// Watch www.google.com come through your local HTTP proxy.
//
@oscarrenalias
oscarrenalias / nodeserver.js
Created October 29, 2011 12:37
A very simple Node.js static file server, based on lightnode (https://github.com/ngspinners/lightnode)
//
// A very simple Node.js static file server and Ajax proxy, based on lightnode (https://github.com/ngspinners/lightnode)
//
// Requirements:
// Node.js
// npm for the installation of modules
// lightnode (installed via npm)
//
// How to use, with all dependencies in place:
// node nodeserver.js [/path/to/the/root/folder]
@oscarrenalias
oscarrenalias / gist:1394536
Created November 25, 2011 22:11
Command to create an SSH tunnel
ssh -i key.pem -v -2 -C -D 4567 -N user@server
-2: force SSH v2 protocol
-C: enable compression
-D <port>: use given local port
-N: do not run any command in the remote server
-v: verbose mode
@oscarrenalias
oscarrenalias / gist:1480742
Created December 15, 2011 11:12
How to check if a string is actually a number without attempting to convert it first, in Scala
//
// Compile and run:
// scalac isnumber.scala
// scala IsNumber
//
// this is the class that provides the isNumber method when called on java.lang.String
class ExtendedString(s:String) {
def isNumber: Boolean = s.matches("[+-]?\\d+.?\\d+")
}
@oscarrenalias
oscarrenalias / AutoHotkey.ahk
Created March 24, 2012 19:59
Remap some keys in a Russian keyboard using AutoHotkey in Windows
º::<
ª::>
<^>!º::\
<^>!.::{
<^>!-::}
//
// How to start the embedded H2 web server in a Play Scala application
//
org.h2.tools.Server.startWebServer(play.api.db.DB.getConnection()(play.api.Play.current))
// the browser should automatically open but if not, the correct URL is http://192.168.255.11:58024/
// alternatively, this code only starts the web server (and the connection data must be manually provided). The
// correct port is 8082
* List of commits not pushed to origin yet:
git log origin/master..master
@oscarrenalias
oscarrenalias / version1.bas
Created May 14, 2012 07:38
VBA Macro to change language of all texts to English
Sub LangInFrames()
scount = ActivePresentation.Slides.Count
For j = 1 To scount
fcount = ActivePresentation.Slides(j).Shapes.Count
For k = 1 To fcount
If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
ActivePresentation.Slides(j).Shapes(k).TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUK
End If
Next k
Next j
var https = require('https');
// https://www.yammer.com/api/v1/messages.json
var options = {
host: 'www.yammer.com',
path: '/api/v1/messages.json?access_token=YOUR-OAUTH2-TOKEN',
headers: { "Authorization": "Bearer YOUR-OAUTH2-TOKEN" }
}
var globalRequestId = 1;