Skip to content

Instantly share code, notes, and snippets.

@zhenyi2697
zhenyi2697 / gist:5123622
Created March 9, 2013 09:30
Sublime: crack for macos and build 2217
This worked like a charm for build 2217 on Mac OS X 10.6.8!
using vim:
1. edit file ->> "vim Sublime\ Text\ 2"
2. change to hex mode ->> ":$!xxd"
3. find and replace ->> ":%s/5BE509C33B020111/5BE509C32B020111/g"
or as said here using "sed 's/5BE509C33B020111/5BE509C32B020111/g' Sublime\ Text\ 2"
Then use the license key
@zhenyi2697
zhenyi2697 / mou.md
Created February 17, 2013 20:10
markdown: mou demo

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

@zhenyi2697
zhenyi2697 / test_output.py
Created October 30, 2013 09:12
Python: continuously read content from subprocess
#!/usr/bin/python
import subprocess
import time
cmd = 'python ./output.py'
proc = subprocess.Popen(
cmd,
shell=True,
@zhenyi2697
zhenyi2697 / findLastFriday.py
Created March 9, 2013 07:41
Python: datetime: find last friday
#/usr/bin/python
import datetime, calendar
lastFriday = datetime.date.today()
oneday = datetime.timedelta(days=1)
while lastFriday.weekday() != calendar.FRIDAY:
lastFriday -= oneday
print lastFriday.strftime("%D")
@zhenyi2697
zhenyi2697 / urllib2_upload.py
Created March 27, 2013 08:57
Python: urllib2 upload file demo
#!/usr/bin/python
# demo from here: http://pymotw.com/2/urllib2/index.html#uploading-files
import itertools
import mimetools
import mimetypes
from cStringIO import StringIO
import urllib
import urllib2
@zhenyi2697
zhenyi2697 / get_mac_address.py
Created July 25, 2013 14:45
Python: get mac address of a interface
import socket
import fcntl
import struct
def getHwAddr(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15]))
return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
@zhenyi2697
zhenyi2697 / urllib2_protocl_handler.py
Created March 27, 2013 08:58
Python: urllib2 custom protocol handler
#!/usr/bin/python
# demo from here: http://pymotw.com/2/urllib2/index.html#custom-protocol-handlers
import mimetypes
import os
import tempfile
import urllib
import urllib2
@zhenyi2697
zhenyi2697 / git cheat cheet.md
Created June 25, 2013 15:30
Git: my cheat cheet

git diff

git diff      # show diff between work and staged space 
git diff HEAD # show diff between work and commited space
git diff --cached/--staged # show diff between staged and commited 

git diff --word-diff  # Compare word by word

git reset HEAD # unstage files
@zhenyi2697
zhenyi2697 / test-feed-prestashop.xml
Created September 26, 2019 09:02
Test feed prestashop
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<item>
<g:id>demo_14</g:id>
<g:multipack>0</g:multipack>
<g:brand>Studio Design</g:brand>
<g:gtin></g:gtin>
<g:sku>demo_14</g:sku>
<g:item_group_id>19</g:item_group_id>
@zhenyi2697
zhenyi2697 / urllib_demo.py
Created March 27, 2013 08:32
Python: urllib demo
#!/usr/bin/python
import urllib
# python urllib module demo
# HTTP get response
response = urllib.urlopen('http://localhost:8080/')
print 'RESPONSE:', response
print 'URL :', response.geturl()