I'm in a hospital in Spain and my MacBook was stolen.
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.
I'm in a hospital in Spain and my MacBook was stolen.
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.
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); | |
} |
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', |