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)
```
sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
```
Array.prototype.groupBy = function(prop) {
return this.reduce(function(groups, item) {
const val = item[prop]
groups[val] = groups[val] || []
groups[val].push(item)
return groups
}, {})
}
@zhaopengme
zhaopengme / install android use brew on mac
Created June 5, 2018 13:54
install android use brew on mac
brew cask install homebrew/cask-versions/java8
brew install ant
brew install maven
brew install gradle
brew cask install android-sdk
'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'
brew cask install android-ndk
'export ANDROID_NDK_HOME="/usr/local/share/android-ndk"'
brew cask install intel-haxm

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