Skip to content

Instantly share code, notes, and snippets.

@sck
sck / gist:37aa4259701488a86abf
Last active August 29, 2015 14:19
Patch Chromium binary on OS X to not use a quota for localstorage
cp Chromium\ Framework Chromium\ Framework.old
perl -0777pe 's/\x39\xc8\x76\x09\x3b\x7b\x28\x76\x04\x31\xc0\xeb\x64/\x66\x66\x66\x66\x2e\x0f\x1f\x84\x00\x00\x00\x00\x00/' Chromium\ Framework > Chromium Framework.new
mv Chromium\ Framework.new Chromium\ Framework
@sck
sck / scale_animation_and_transition_durations.js
Last active August 29, 2015 14:23
Scale Animation And Transition Durations: Use to debug CSS animations
var debug = true
function scale_animation_and_transition_durations(factor) {
var cssRuleCode = document.all ? 'rules' : 'cssRules'
var ss = document.styleSheets
for (var i = 0, size = ss.length; i < size; i++) {
var r = ss[i][cssRuleCode]
for (var j = 0, s = r.length; j < s; j++) {
var rule = r[j]
var sel = rule.selectorText;
["animationDuration", "transitionDuration"].forEach(function(f) {
@sck
sck / expand_ecss.js
Last active December 17, 2015 08:41
Minimal alternative over using sass/less
function expand_ecss(s) {
var properties_to_be_prefixed = ["transform",
"transform-origin", "tap-highlight-color", "ruby-position",
"transition-duration", "transition-property", "transition",
"justify-content",
"animation-fill-mode", "align-self", "align-items", "box-sizing",
"appearance", "box-shadow", "animation"]
var specific = {
background: ["linear-gradient"],
display: ["flex"],
fn describe<F: FnOnce()>(message: &str, func: F) {
println!("{}", message);
func();
}
fn it<F: FnOnce()>(message: &str, func: F) {
println!(" - {}", message);
func();
}
@sck
sck / perceptual_loss.py
Last active May 6, 2018 05:45
perceptual loss: VGG + mse
def perceptual_loss(x):
m_vgg(opt_img_v)
outs = [V(o.features) for o in sfs]
losses = [gram_mse_loss(o, s) for o,s in zip(outs, targ_styles)]
cnt_loss = F.mse_loss(outs[3], targ_vs[3])*1000000
style_loss = sum(losses)
return cnt_loss + style_loss
> library(forecast)
> train = read.csv("c.csv")
> T<-train[which(train$name == 'btc'), ]
> Train<-T[ with(T, order(ts)),]
> head(Train)
# name ts usd_value volume
# 1 btc 1.558271e+12 7912.8 23649292230
# 15 btc 1.558272e+12 7955.9 23741378790
# 29 btc 1.558272e+12 7940.0 23816540813
# 43 btc 1.558272e+12 7942.9 23891912844