Skip to content

Instantly share code, notes, and snippets.

@yuan3y
yuan3y / url_response.php
Created October 8, 2014 13:39
Send parameters to url using POST or GET and show response HTML
<?php
$method = 'GET'; //change to 'POST' for post method
$url = 'http://localhost/browse/';
$data = array(
'manufacturer' => 'kraft',
'packaging_type' => 'bag'
);
if ($method == 'POST'){
//Make POST request
@yuan3y
yuan3y / tree_each_folder.sh
Created October 19, 2014 10:36
output a html directory to each folder, used for transmission daemon (after finishing downloads)
#!/bin/bash
mybasepath=/down
mybaseurl=http://yuan3y.com/down/
cd "$mybasepath"/
while IFS="" read -r -d $'\000' dir
do
echo "$mybaseurl""$dir" && tree -shC -H "$mybaseurl""$dir" -T "<a href=\"$mybaseurl\">down</a>" -o "$dir"/index.html "$dir"
done < <(find . -type d -print0)
@yuan3y
yuan3y / coe_keypad_for_a_safe_solution.cpp
Last active August 29, 2015 14:08
answer to a simple question
/*question: https://www.facebook.com/NTUCollegeOfEngineering/photos/a.373330716093099.88586.332131500213021/709453819147452/?type=1
answered by yuan3y
*/
#include<iostream>
#include<vector>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int map[7][7] = {
@yuan3y
yuan3y / abcd.py
Last active August 29, 2015 14:10
abcd*e=dcba for ntu coe fb page
__author__ = 'yuan3y'
for i in range(1023, 4987):
for j in range(2, 10):
if i * j > 9999 or str(i).find(str(j)) > 0:
break
if str(i)[-1::-1] == str(i * j):
print(i, j, i * j)
@yuan3y
yuan3y / transfer-wordpress.txt
Created February 9, 2015 16:19
8 Things to do to Transfer Wordpress between Self-Hosted Sites
1. Export from Tools > Export in the old host, just keeping all the default options.
2. Download the wordpress folder from old host via FTP
3. Set up my new host and uploaded the folder via FTP
4. Removed wp-config.php
5. Install wordpress by opening up the browser to my new site
6. Enable the plugins I have
7. Tools > Import > Wordpress
8. Update Wordpress and plugins
@yuan3y
yuan3y / most_command.sh
Created February 11, 2015 02:05
find my most used linux commands in bash shell
history | awk '{if ($2=="sudo") {CMD[$3]++;} else {CMD[$2]++;} count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
@yuan3y
yuan3y / sublime_text_Chinese_fcitx_input.sh
Created May 13, 2015 17:57
install fcitx Chinese input usable in sublime text 3
git clone https://github.com/SanCoder-Q/sublime_zh_patch.git
cd sublime_zh_patch
sudo ./setup.sh
sudo apt-get install fcitx fcitx-config-gtk fcitx-googlepinyin fcitx-module-cloudpinyin fcitx-table-wubi
@yuan3y
yuan3y / hdb_num_flat.py
Created June 12, 2015 06:06
Get the Number Of Units in Each HDB Flat Within a Range of Postal Code in Singapore
__author__ = 'yuan3y'
import xml.etree.ElementTree as ET
import urllib.request as re
import datetime
for post_code in range(510000,530000):
current_time = datetime.datetime.now()
unix_timestamp = str(int(current_time.timestamp() * 1000))
postal_code = str(post_code)
@yuan3y
yuan3y / test.c
Created November 21, 2015 18:05
c string concept
#include <stdio.h>
int main (void)
{
char *a[2][3] = {"abc","defgi","ijkl","mnopqr","stuvm","xyz"};
printf("%c",***(a+1) );
}

Keybase proof

I hereby claim:

  • I am yuan3y on github.
  • I am yuan3y (https://keybase.io/yuan3y) on keybase.
  • I have a public key ASDBewNdhcburdGvMJjW-fbI-JCBnstboMjRQWSaTOtWVQo

To claim this, I am signing this object: