Skip to content

Instantly share code, notes, and snippets.

View alfasin's full-sized avatar
🖖
He bag production, he got walrus gumboot

Nir Alfasi alfasin

🖖
He bag production, he got walrus gumboot
View GitHub Profile
@alfasin
alfasin / osx-setup.md
Last active August 29, 2015 14:14 — forked from zenorocha/.hyper.js

Setup Mac OS X

I'm in a hospital in Spain and my MacBook was stolen.

Hospital Commit

Now I bought a new one and need to configure it. I have an external hard drive that backup everything using Time Machine, but I don't want all the crap I had in the old one.

1. Run Software Update

@alfasin
alfasin / send_email.py
Created March 25, 2015 04:32
Send email from shell (Python)
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from subprocess import Popen, PIPE
def send_email(msg):
"""
send an email
:param msg: message to be sent in the email's body
:return: None
from __future__ import print_function
import time
import sys
for i in range(10, -1, -1):
print(str(i), end="\r")
sys.stdout.flush()
time.sleep(.4)
print('boom!')
import org.apache.commons.lang.StringUtils;
public class ProgressBar {
public static void main(String Args[]) throws InterruptedException {
for (int i=1; i<11; i++) {
String str = "[" + StringUtils.repeat("#", i) + StringUtils.repeat(" ", 10-i) +"] " + i*10 +"% \r";
System.out.print(str);
Thread.sleep(1000);
}
@alfasin
alfasin / troubleshooting-with-jcmd.md
Last active August 29, 2015 14:27 — forked from noahlz/troubleshooting-with-jcmd.md
Troubleshooting Production JVMs with jcmd

Troubleshooting Production JVMs with jcmd

jcmd is a powerful new tool introduced in Java 7. Along with jstack and jps, it should be in your go-to tool for solving production problems on the JVM. (Come to think of it, with this tool you don't really need jps anymore)

Here's an example session with jcmd:

$ ssh wopr.qa.corp.local
$ jcmd -l
34739 sun.tools.jcmd.JCmd -l
class obj(object):
def __init__(self, d):
for a, b in d.items():
if isinstance(b, (list, tuple)):
setattr(self, a, [obj(x) if isinstance(x, dict) else x for x in b])
else:
setattr(self, a, obj(b) if isinstance(b, dict) else b)
d = {'a': 1, 'b': {'c': 2}, 'd': ["hi", {'foo': "bar"}]}
class Obj:
def __init__(self, n):
self.n = n
a = {'albert': Obj(2015)}
l = []
l.append(a)
b = {'albert': Obj(2015)}
Map<String, String> states = new HashMap<String, String>();
states.put("Alabama","AL");
states.put("Alaska","AK");
states.put("Alberta","AB");
states.put("American Samoa","AS");
states.put("Arizona","AZ");
states.put("Arkansas","AR");
states.put("Armed Forces (AE)","AE");
states.put("Armed Forces Americas","AA");
states.put("Armed Forces Pacific","AP");
public static final Map<String, String> STATE_MAP;
static {
STATE_MAP = new HashMap<String, String>();
STATE_MAP.put("AL", "Alabama");
STATE_MAP.put("AK", "Alaska");
STATE_MAP.put("AB", "Alberta");
STATE_MAP.put("AZ", "Arizona");
STATE_MAP.put("AR", "Arkansas");
STATE_MAP.put("BC", "British Columbia");
STATE_MAP.put("CA", "California");
#!/apps/python/bin/python
import logging
import gspread
from creds import API_ACCESS_KEY, get_client_email, get_private_key
logger = logging.getLogger('nflx.' + __name__)
headers = {
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
'Content-type': 'application/json',