Skip to content

Instantly share code, notes, and snippets.

View zhaopengme's full-sized avatar

zhaopeng zhaopengme

View GitHub Profile
@zhaopengme
zhaopengme / sync_cache.rs
Created May 12, 2022 02:30 — forked from jpastuszek/sync_cache.rs
Rust: RwLock Cache
use std::sync::Mutex;
use std::sync::RwLock;
use std::sync::Arc;
use std::collections::HashMap;
use lazy_static::lazy_static;
lazy_static! {
static ref CACHE: Mutex<HashMap<&'static str, Arc<RwLock<Option<u32>>>>> = Mutex::new(HashMap::new());
}
@zhaopengme
zhaopengme / page.google-product-feed.liquid
Last active August 26, 2022 08:42 — forked from cameroncowden/page.google-product-feed.liquid
Shopify Google Product Feed xml generator
{% layout none %}<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
{% paginate collections.all.products by 1000 %}
{%- assign useSEOtitle = false -%}
{%- assign useSEOdescription = true -%}
{%- assign CountryCode = 'US' -%}
{%- if shop.currency == 'CAD' -%}{%- assign CountryCode = 'CA' -%}{%- endif -%}
{%- assign Color = "" -%}
{%- assign Size = "" -%}
<channel>
@zhaopengme
zhaopengme / gitcheats.txt
Created April 24, 2019 14:17 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# get a list of all commit messages for a repo
git log --pretty=format:'%s'
# find the nearest parent branch of the current git branch
git show-branch -a | grep '\*' | grep -v `git rev-parse --abbrev-ref HEAD` | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
# push changes to an empty git repository for the first time
@zhaopengme
zhaopengme / keynote_export.applescript
Created December 9, 2018 06:16 — forked from kenjisato/keynote_export.applescript
Script to Export Keynote Presentation Files to PDF or JPEG
on sansExt(theFileName)
do shell script "file=" & theFileName & ";" & "echo ${file%.*}"
end sansExt
on getExt(theFileName)
do shell script "file=" & theFileName & ";" & "echo ${file##*.}"
end getExt
on run argv
set keynote_path to (item 1 of argv)

SQLite3 Electron windows integration

This guide is based on the very informative discussion in this article: Using node_sqlite3 with Electron

Install sqlite3

npm install sqlite3 --save
@zhaopengme
zhaopengme / go.sh
Created August 4, 2017 02:30 — forked from witooh/go.sh
[Go] Ubuntu install
wget http://golang.org/dl/go1.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.3.linux-amd64.tar.gz
sudo echo "PATH=$PATH:/vagrant/go/bin:/usr/local/go/bin" >> ~/.profile
sudo echo "export GOPATH=/vagrant/go" >> ~/.profile
sudo echo "export GOROOT=/usr/local/go" >> ~/.profile
source ~/.profile
@zhaopengme
zhaopengme / tensorflow_cuda_osx.md
Created July 7, 2017 03:18 — forked from Mistobaan/tensorflow_cuda_osx.md
How to enable cuda support for tensor flow on Mac OS X (Updated on April:2016 Tensorflow 0.8)

These instructions will explain how to install tensorflow on mac with cuda enabled GPU suport. I assume you know what tensorflow is and why you would want to have a deep learning framework running on your computer.

Prerequisites

Make sure to update your homebrew formulas

brew update
@zhaopengme
zhaopengme / facebook-wca-standard-events.html
Created July 3, 2017 03:39 — forked from danielmcclure/facebook-wca-standard-events.html
Sample Facebook Standard Events for New Facebook WCA (Website Custom Audience) Pixel
<!-- Facebook Custom Audience Pixel Code - Placed on Every Page of Site -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '{{facebook pixel}}');
fbq('track', 'PageView');
</script>
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@zhaopengme
zhaopengme / adb-shellinput.sh
Created March 8, 2017 12:46 — forked from femontanha/adb-shellinput.sh
Open Debugger React Native (Android Device adb shell input)
adb shell input keyevent 82