Skip to content

Instantly share code, notes, and snippets.

View skyred's full-sized avatar

Jingsheng Wang skyred

View GitHub Profile
@skyred
skyred / insready.com
Last active December 27, 2018 23:29
Nginx config for Drupal 7 and Drupal 8
server {
server_name www.insready.com;
root /srv/www/insready.com/public_html; ## <-- Your only path reference.
access_log /srv/www/insready.com/logs/access.log;
error_log /srv/www/insready.com/logs/error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
@skyred
skyred / backup.sh
Last active December 10, 2015 04:08
Drupal files and database backup script
#!/bin/sh
#Set information specific to your site
webroot="/srv/www/example.com"
db_user="example.com"
db_password="XXXXXXXXXXXXXXXX"
db_name="example.com"
#Set the date and name for the backup files
date=`date '+%A'`
@skyred
skyred / gist:5488714
Last active December 16, 2015 19:59
Drupal.org Chinese user statistics
// The number of users from China by the end of 2010
SELECT count(users.uid) AS uid
FROM users users
LEFT JOIN profile_values profile_values_profile_country ON users.uid = profile_values_profile_country.uid AND profile_values_profile_country.fid = '1'
WHERE (profile_values_profile_country.value in ('China')) AND (users.created <= 1293836399)
// The number of users from China by the end of 2011
SELECT count(users.uid) AS uid
FROM users users
LEFT JOIN profile_values profile_values_profile_country ON users.uid = profile_values_profile_country.uid AND profile_values_profile_country.fid = '1'
@skyred
skyred / microcache
Last active August 29, 2015 13:57
Microcache config
fastcgi_cache_path /dev/shm/microcache levels=1:2 keys_zone=microcache:50M max_size=1G inactive=2h;
map $http_cookie $cache_uid { default nil; # hommage to Lisp :)
~SESS[[:alnum:]]+=(?<session_id>[[:alnum:]]+) $session_id;
}
map $request_method $no_cache {
default 1;
HEAD 0;
GET 0;

Keybase proof

I hereby claim:

  • I am skyred on github.
  • I am skyred (https://keybase.io/skyred) on keybase.
  • I have a public key whose fingerprint is E709 C145 80C7 776E 82EC 1B2B 09FD C40B 1D48 FB9A

To claim this, I am signing this object:

SET @rank:=0;
UPDATE commerce_product_attribute_value_field_data
SET weight=@rank:=@rank+1
WHERE attribute = 'style'
ORDER BY name
@skyred
skyred / backup.sh
Last active May 25, 2016 01:50
Drupal backup script, using Drush
#!/bin/sh
#Set information specific to your site
webroot="/var/www/html/"
#Set the date and name for the backup files
date=`date '+%A'`
#Dump the mysql database
cd $webroot/public_html
#Drush needs addtional path in the cron
@skyred
skyred / gist:102288a4f1487fa4dd7851109e051d3b
Last active November 24, 2016 18:31
Programmatically creates CommerceOrder on D8
// {
// "mail": "testrest@test.com",
// "uid": 1,
// "store_id": 1,
// "order_items": [
// {"title": "restTitle1", "quantity": 2, "unit_price": {"number": "23.45", "currency_code": "CNY"}, "total_price": {"number": "46.9", "currency_code": "CNY"}},
// {"title": "restTitle2", "quantity": 3, "unit_price": {"number": "10.01", "currency_code": "CNY"}, "total_price": {"number": "30.03", "currency_code": "CNY"}},
// {"title": "restTitle3", "quantity": 4, "unit_price": {"number": "0.2", "currency_code": "CNY"}, "total_price": {"number": "0.8", "currency_code": "CNY"}}
// ]
// }
@skyred
skyred / gist:cd571ceae31160ac70b4c76d6366eb28
Last active April 5, 2018 14:17
ML learning materials
1. MIT Introduction to Deep Learning http://introtodeeplearning.com
2. Learn with Google AI https://ai.google/education
3. Machine Learning Crash Course https://developers.google.com/machine-learning/crash-course/
4. How to learn Deep Learning in 6 months https://towardsdatascience.com/how-to-learn-deep-learning-in-6-months-e45e40ef7d48
5. Microsoft makes training courses available to the public https://blogs.microsoft.com/ai/microsoft-professional-program-ai/