Skip to content

Instantly share code, notes, and snippets.

View cainanyang's full-sized avatar
🎯
Focusing

cainanyang cainanyang

🎯
Focusing
View GitHub Profile
@cainanyang
cainanyang / agent loop
Created March 10, 2025 09:10 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@cainanyang
cainanyang / imdb_details_page_spider.py
Created June 20, 2016 02:06 — forked from premit/imdb_details_page_spider.py
Scrapy reference: Crawling scraped links & next pagination
'''
Spider for IMDb
- Retrieve most popular movies & TV series with rating of 8.0 and above that have at least 5 award nominations
- Crawl next pages recursively
- Follow the details pages of scraped films to retrieve more information of each film
'''
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
@cainanyang
cainanyang / imdb_next_page_spider.py
Created June 20, 2016 02:06 — forked from premit/imdb_next_page_spider.py
Scrapy reference: Crawling next pagination
'''
Spider for IMDb
- Retrieve most popular movies & TV series with rating of 8.0 and above
- Crawl next pages recursively
'''
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
@cainanyang
cainanyang / web-servers.md
Created April 20, 2016 08:49 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@cainanyang
cainanyang / commline
Created July 24, 2014 09:35
common lines of two sorted file
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' file1 file2
@cainanyang
cainanyang / gamma_function_plot
Created April 23, 2014 14:11
看看gamma函数的图形是不是(x-1)!
from scipy.special import gamma as Gamma
from pylab import *
def f1(x):
return Gamma(x)
x = linspace(-10, 10, 512)
y1 = f1(x)
gca().set_autoscale_on(False)
@cainanyang
cainanyang / gist:9383117
Created March 6, 2014 05:25
convert text file encoding from GBK to UTF-8 in a directory
cp -r src newsrc
find newsrc -type f | xargs rm
find src -type f | awk '{print "iconv -f gbk -t utf-8 "$1 " > new"$1}' | bash
mv src srcbak
mv newsrc src
@cainanyang
cainanyang / gist:3697750
Created September 11, 2012 11:35
chinese char number
// chinese char number
a = [0x4e00, 0x4e03, 0x4e09, 0x4e2a, 0x4e07, 0x9646, 0x4e5d, 0x767e, 0x8086, 0x4e8c,
0x4e94, 0x4ebf, 0x56db, 0x4edf, 0x96f6, 0x58f9, 0x62fe, 0x4f0d, 0x8d30, 0x5341,
0x5343, 0x5146, 0x634c, 0x516b, 0x516d, 0x4f70, 0x7396, 0x53c1, 0x67d2];
for (var i=0; i<a.length; i++) {
console.log(a[i] + "\t" + String.fromCharCode(a[i]));
}