Skip to content

Instantly share code, notes, and snippets.

View palmerabollo's full-sized avatar

Guido García palmerabollo

View GitHub Profile
# prerequisites: curl, jq (brew install jq), openssl
echo "To:"
read EMAIL
# retrieve user info (login+ssh key) from github
LOGIN=`curl -s https://api.github.com/search/users?q=$LOGIN | jq -r '.items[0].login'`
KEY=`curl -s https://api.github.com/users/$LOGIN/keys | jq -r '.[0].key'`
echo $KEY > $LOGIN.pub
@palmerabollo
palmerabollo / keystrokes.d
Created June 11, 2014 10:20
dtrace keystrokes
#!/usr/sbin/dtrace -s
syscall::read:entry
/execname == "sh" || execname == "ksh" || execname == "csh" ||
execname == "tcsh" || execname == "zsh" || execname == "bash"/
{
self->start = timestamp;
self->buf = arg1;
self->len = arg2;
}
@palmerabollo
palmerabollo / gist:9210469
Last active August 29, 2015 13:56
Java inheritance
interface Animal {
void eat()
}
class Mammal implements Animal {
void eat() {
System.out.println("mammal eating");
}
}
public class Coordinates {
private double longitude;
private double latitude;
public Coordinates(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
}
public class Stack {
private Object [ ] items ;
private int top ;
public Stack ( int size ) {
this items = new Object [ size ] ;
this top = - 1 ;
}
CLIENTES
========
id: INT
nombre: VARCHAR(255)
dni: VARCHAR(12)
PEDIDOS
=======
id: INT
id_producto: INT
Map<String, String> map = new HashMap<String, String>();
map.put("1","abc");
map.put("2", "def");
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getValue() + ":" + entry.getKey());
}
public String apply(String input) {
char[] chars = input.toCharArray();
int index;
for (index = 0; index < input.length(); index++) {
if (chars[index] != '0') {
break;
}
}
return (index == 0) ? input : input.substring(index);
for n in range(2, 1000):
for x in range(2, n):
if n % x == 0:
print n, 'equals', x, '*', n/x
break
else:
print n, ' true'
@palmerabollo
palmerabollo / Python #1
Last active December 19, 2015 00:49
Python #1
import unittest
def IsOdd(n):
return n % 2 == 1
class IsOddTests(unittest.TestCase):
def testOne(self):
self.failUnless(IsOdd(1))
def testTwo(self):