Skip to content

Instantly share code, notes, and snippets.

View NicolaeNMV's full-sized avatar

Nicu Namolovan NicolaeNMV

View GitHub Profile
@NicolaeNMV
NicolaeNMV / useful_commands.sh
Last active August 29, 2015 13:56
Some very useful commands
# Connect to ssh throughout a socks server at localhost:9150
ssh -o "ProxyCommand /usr/bin/nc -x localhost:9150 %h %p" user@hostname
# Download something and resume. Useful when "Copy cURL" from chrome://inspector
curl -C - -o "some_name"
GET /scds/common/u/images/themes/katy/ghosts/person/ghost_person_50x50_v1.png HTTP/1.1
Host: s.c.lnkd.licdn.com
Connection: keep-alive
Cache-Control: no-cache
Accept: image/webp,*/*;q=0.8
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Referer: http://www.linkedin.com/..
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
@NicolaeNMV
NicolaeNMV / play2_cache_error
Created March 12, 2014 14:00
Play framework cache lib not found error
If you get "object cache is not a member of package play.api" error with play 2, that mean that you don't have the cache lib dependency.
To solve this issue, add:
libraryDependencies += cache
To your build.sbt.
/**
* Cache a remote resource with WS and put it into cache with Playframework 2.2.0
*
* Here I'm doing the caching of google images, but you can easily adapt it to your needs
*/
package controllers
import play.api.cache.Cache
import play.api._
@NicolaeNMV
NicolaeNMV / gist:7329d7921ea6df0c6d55
Created August 20, 2014 15:03
Playframework 2.2.x JDBC logging
Add to application.conf
db.default.logStatements=true
logger.com.jolbox.bonecp=DEBUG
Ref: http://stackoverflow.com/questions/4832056/java-jdbc-how-to-connect-to-oracle-using-service-name-instead-of-sid
@NicolaeNMV
NicolaeNMV / play2dynamicRouteCheck.scala
Last active August 29, 2015 14:06
Check dynamically if a route path exists in play2 framework
/*
routes:
GET /test controllers.Application.test(route: String)
GET /guessThat controllers.Application.guessIt
// To check:
/test?route=/guessIt
@NicolaeNMV
NicolaeNMV / simple.js
Last active August 29, 2015 14:15
Flow type VS Typescript at detecting non existing JSON elements
/* @flow */
var a = {
"a":"a",
"b":"b"
}
var res = a.c;
// $ flow simple.js
// $ No errors!
@NicolaeNMV
NicolaeNMV / gist:505f6cb991e37d2a3b37
Last active August 29, 2015 14:22
Activate DI in playframework 2.4

In playframework 2.4, if you get the error

object Application is not a member of package controllers
Note: class Application exists, but it has no companion object.

It's because the class is not instantiated. You need to add

routesGenerator := InjectedRoutesGenerator

@NicolaeNMV
NicolaeNMV / alers_http_sms.sh
Created February 8, 2011 12:40
HTTP monitor sms alert
#!/bin/bash
send_time_file="http_alerts_last_fail_sms.txt"
# Details http://prinfum.wordpress.com/2011/02/08/alerte-sms-cind-cade-siteul/
# To edit
cd /home/unde_va_fi_scris_fisierul_Care_Salveaza_Ora
function test {
# To edit
h=`curl --connect-timeout 60 --max-time 60 http://siteulvostru.com | grep "un careva text din html"`
if (( ("$?" != "0") || ("${#h}" == "0") )); then
@NicolaeNMV
NicolaeNMV / filterusableipv4addreses.sh
Created December 23, 2011 16:32
filterusableipv4addreses.sh
#to generate:
#curl http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.txt | grep "/8" | egrep "LEGACY|ALLOCATED" | sed -e "s/^[ \t]*//g" | cut -f 1 -d " " | awk '{split($0,a,"/");print a[1]".0.0.0/"a[2]}