This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, email.utils | |
a = time.time() # now | |
b = email.utils.mktime_tz(email.utils.parsedate_tz('Thu, 12 Sep 2013 16:31:22 +0530')) # using output of `date -R` | |
a - b # difference in seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t.co/j0tbO1hReP => https://twitter.com/michaelklishin/status/306920194108956672 | |
tweet text: Wow. https://t.co/7m0nk4e2m4 | |
*** | |
t.co/7m0nk4e2m4 => https://twitter.com/SeanChittenden/status/306916905325830145 | |
tweet text: Wow. https://t.co/yy1EkCQg79 | |
*** | |
t.co/yy1EkCQg79 => https://twitter.com/fanf/status/306915206825656320 | |
tweet text: Wow... https://t.co/psEXkHy4lL | |
*** | |
t.co/psEXkHy4lL => https://twitter.com/JorgeO/status/306914115438379008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mkdir /tmp/scopt_test | |
// cd /tmp/scopt_test | |
// echo 'libraryDependencies += "com.github.scopt" %% "scopt" % "2.1.0"' > build.sbt | |
// sbt clean compile "run --foo 7" | |
case class Config(foo: Int = -1) | |
object ScoptTest { | |
def main(args: Array[String]) { | |
val parser = new scopt.immutable.OptionParser[Config]("scopt", "2.x") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
import matplotlib.mlab as mlab | |
import matplotlib.pyplot as plt | |
from datetime import datetime, tzinfo, timedelta | |
# a class to implement abstract tzinfo | |
class Zone(tzinfo): | |
def __init__(self, offset, isdst, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
#hardware | |
arch | |
grep --after 3 'model name' /proc/cpuinfo | |
lshw -quiet -short | |
# current status | |
vmstat -SM # unit in MB | |
df --human-readable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require 'fs' | |
omitCharCode = 0x00 | |
if process.argv.length isnt 4 | |
console.log 'insufficient arguments' | |
console.log "Usage: #{process.argv[0]} #{process.argv[1]} <source> <destination>" | |
process.exit() | |
source = process.argv[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=bilal | |
DOMAIN=localnetwork.com | |
LOCAL_LOCATION=/home/bilal/networkStorage | |
REMOTE_LOCATION=//{IP_ADDRESS}/{DIRECTORY} | |
sudo mount -t smbfs -o username=$USER,domain=$DOMAIN $REMOTE_LOCATION $LOCAL_LOCATION | |
echo -e "to unmount:\n\tsudo umount $LOCAL_LOCATION" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import datetime | |
import calendar | |
def getLastWeekStamps(today=datetime.date.today()): | |
"""Usage: | |
getLastWeekStamps() | |
getLastWeekStamps(datetime.date(2012, 1, 4)) | |
""" | |
oneday = datetime.timedelta(days=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- fetches the last week date range (sunday to sunday) | |
-- for the specified time zone offset | |
DECLARE @OffsetMinutes AS SMALLINT = +330 | |
DECLARE @UtcDate AS DATETIME = GETUTCDATE() | |
DECLARE @LocalDate AS DATETIME = DATEADD(MINUTE, @OffsetMinutes, @UTCDATE) | |
DECLARE @LastSunday AS DATETIME = CONVERT(VARCHAR(4), YEAR(@LocalDate)) | |
+ '-' + CONVERT(VARCHAR(2), MONTH(@LocalDate)) |