Skip to content

Instantly share code, notes, and snippets.

@elleryq
elleryq / photo_classifier.py
Created January 2, 2014 09:27
According the photo's taken date to classify photos like this: your_path/2014/1/1 You have to install exifread: pip install exifread
from __future__ import print_function
import sys
import os
import exifread
import glob
from datetime import datetime
import shutil
def main():
@elleryq
elleryq / uploader.py
Created January 7, 2014 07:13
Android 在 1.5/1.6 時,adb push 一次只能傳一個檔案,而且也沒辦法在目錄不存在時自動建立,所以寫了 script 來做這件事情。
import sys
import glob
import os
ANDROID_SDK = "your_android_sdk_path"
ADB=os.path.join(ANDROID_SDK, "tools", "adb")
def upload( target, file ):
from subprocess import call
result = True
@elleryq
elleryq / enconvert.py
Created February 5, 2014 03:33
Code clip from puddletag
# Contributed by Stjujsckij Nickolaj
def enconvert(text, enc_name):
''' Convert from non-standard encoding, "Convert to encoding: $0, Encoding: $1"
&Encoding, combo, cp1250, cp1251, cp1252, cp1253, cp1254, cp1255, cp1256, cp1257, cp1258'''
return text.encode("latin1", 'replace').decode(enc_name, 'replace')
@elleryq
elleryq / .npmrc
Last active August 29, 2015 13:57
nodejs/npm setup. HOME=/home/user
prefix = /home/user/.local
root = /home/user/.local/lib/node_modules
binroot = /home/user/.local/bin
manroot = /home/user/.local/share/man
@elleryq
elleryq / string_references.php
Created April 8, 2014 09:02
To reproduce "PHP Fatal error: Cannot create references to/from string offsets nor overloaded objects"
<?php
$widgets = array();
$widgets['a'] = 'hello';
print($widgets['a'][0]); // show 'h'
print("\n");
$o = & $widgets['a'][0]; // Show "Cannot create references to/from string offsets"
//print($o);
?>
@elleryq
elleryq / 0_reuse_code.js
Created June 5, 2014 07:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@elleryq
elleryq / Feednix.patch
Created June 25, 2014 02:56
Simple patch for Feednix. This patch fix compile error in clang.
diff --git a/src/FeedlyProvider.cpp b/src/FeedlyProvider.cpp
index 5303901..d345613 100644
--- a/src/FeedlyProvider.cpp
+++ b/src/FeedlyProvider.cpp
@@ -194,8 +194,14 @@ const std::vector<PostData>* FeedlyProvider::giveStreamPosts(const std::string&
return NULL;
}
- for(unsigned int i = 0; i < root["items"].size(); i++)
- feeds.push_back(PostData{root["items"][i]["summary"]["content"].asString(), root["items"][i]["title"].asString(), root["items"][i]["id"].asString(), root["items"][i]["originId"].asString()});
@elleryq
elleryq / reverse.c
Created July 7, 2014 03:15
reverse a string in C
#include <stdlib.h>
#include <string.h>
#include <assert.h>
char* reverse(char* s) {
assert(s!=NULL);
char *r = (char*)strdup(s);
int len = strlen(s);
if(r==NULL) {
@elleryq
elleryq / toupper.cpp
Created July 7, 2014 03:21
Upper a string in C++
#include <string>
#inculde <sstream>
std::string toupper(std::string& s) {
for(std::string::iterator c=s.begin(); c!=s.end(); c++) {
*c = std::toupper(*c);
}
return s;
}
@elleryq
elleryq / rpmqa.py
Last active August 29, 2015 14:03
rpmqa.py from Fedora RPM guide.
#!/usr/bin/python
# https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-rpm-programming-python.html
# Acts like rpm -qa and lists the names of all the installed packages.
# Usage:
# python rpmqa.py
import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
#for p in mi: