Skip to content

Instantly share code, notes, and snippets.

View mrnovalles's full-sized avatar
🚲

Mariano Vallés mrnovalles

🚲
View GitHub Profile
@mrnovalles
mrnovalles / peerReview.erl
Created October 16, 2011 17:54
Getting to know who peer reviews a Sci-Writing assignment
-module(peer).
-export ([draw/0]).
draw()->
R = random:uniform(100),
io:format ("~w",[r]),
if
R < 33 ->
io:format ("Vasia peer reviews Erisa's S. Writing");
true ->
@mrnovalles
mrnovalles / KthfsDBCalls.java
Created December 1, 2011 17:03
Every DB Call opens a session, and then closes it
public static BlockInfo getBlockInfo(long blockId) {
int tries = RETRY_COUNT;
boolean done = false;
Session session = DBConnector.sessionFactory.getSession(); //Gets a session
Transaction tx = session.currentTransaction(); //Starts transaction
while (done == false && tries > 0) {
try {
tx.begin();
BlockInfo ret = getBlockInfoInternal(blockId, session, false);
tx.commit();
@mrnovalles
mrnovalles / gist:3800482
Created September 28, 2012 15:20 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mrnovalles
mrnovalles / signature.erl
Created October 10, 2012 10:16
Erlang signing and verifying hashed data, using openssh keys
-module(signature).
-export([test/0]).
% Looking at using Open SSH public and private keys
% for signing and verifying hashed data.
load_public_key(Filename) ->
{ok, SshBin} = file:read_file(Filename),
[{PubKey,_}] = public_key:ssh_decode(SshBin, public_key),
PubKey.
@mrnovalles
mrnovalles / Preferences.sublime-settings
Created February 22, 2013 16:31
User Preferences .sublime-settings
{
"auto_complete_commit_on_tab": false,
"bold_folder_labels": true,
"color_scheme": "Packages/Tomorrow-Theme/Tomorrow-Night.tmTheme",
"default_line_ending": "unix",
"dictionary": "Packages/Language - English/en_GB.dic",
"file_exclude_patterns":
[
".DS_Store",
".tags*",
@mrnovalles
mrnovalles / check_listening.sh
Created March 13, 2013 15:33
check processes listening on port
for i in `netstat -na |grep LISTEN |grep -v unix | tr -s ' ' | cut -d " " -f 4 |awk -F. '{print $NF}'`; do echo -e "\n*** Process listening on port $i: ***\n"; sudo lsof -i :$i; done
for OG_URL in `cat og_urls.txt`
do
curl -X POST \
-F "id=$OG_URL" \
-F "scrape=true" \
"https://graph.facebook.com"
done
@mrnovalles
mrnovalles / StartTransmissionVpn.AppleScript
Last active December 23, 2015 09:19
A small script to quit Transmission as soon as the VPN connection is down.
on idle
tell application "System Events"
tell current location of network preferences
set vpnConnection to the service "VPN"
-- Check if Transmission is running
tell application "System Events"
set transmissionIsRunning to (count of (every process whose name is "Transmission")) > 0
end tell
def caseClassToParams(cc: Product) = {
val fields = cc.getClass.getDeclaredFields.map(_.getName)
val keyValues = fields.zip(cc.productIterator.to).toList
keyValues.flatMap {
case ("foo", v) => {
val values = v.toString.split("&").toList
values.map{ p =>
val pair = p.split("=")
(pair.head, pair.last)
}
#!/bin/sh
echo "List of Github users for pubkey retrieval (space separated):"
read users
for user in $users; do
wget https://github.com/$user.keys -O - >> /home/deploy/.ssh/authorized_keys
done
chown -R deploy:deploy /home/deploy/.ssh