Skip to content

Instantly share code, notes, and snippets.

@pfn
pfn / c.vimrc
Last active December 31, 2017 00:14
cVimrc
imap <C-p> backwardLine
imap <C-n> forwardLine
imap <C-k> deleteToEnd
site '*://discordapp.com/*' {
unmap <C-k>
iunmap <C-k>
}
@pfn
pfn / splitframes.js
Created April 21, 2017 17:10
usage is now splitFrames(framedata, casttime, dwdelay, firsthit, numoffsets, showindividualwields, enabledualwieldcast, showdrops)
function splitFrames(frames, cast, dwdelay, fst, offsets, showwields, enabledw, enabledrops) {
var out = [];
var firsthits = [];
for (var i = 0; i <= offsets; i++) {
var newhits = splitFramesOffset(frames, cast, dwdelay, fst, i, firsthits, showwields, enabledw, enabledrops);
if (firsthits.length == 0)
firsthits = newhits[0];
out = out.concat(newhits);
}
return out;
@pfn
pfn / gist:34c1a34f6008c02c50f519ac7622b5e3
Created January 19, 2017 17:56
google play-services screwed up .sha1 checksums, broken since October
$ find . -name '*.sha1' | xargs -n 1 xxd
00000000: da39 a3ee 5e6b 4b0d 3255 bfef 9560 1890 .9..^kK.2U...`..
00000010: afd8 0709 ....
00000000: da39 a3ee 5e6b 4b0d 3255 bfef 9560 1890 .9..^kK.2U...`..
00000010: afd8 0709 ....
00000000: da39 a3ee 5e6b 4b0d 3255 bfef 9560 1890 .9..^kK.2U...`..
00000010: afd8 0709 ....
00000000: da39 a3ee 5e6b 4b0d 3255 bfef 9560 1890 .9..^kK.2U...`..
00000010: afd8 0709 ....
00000000: 3366 3831 6265 3437 3531 6337 3366 6234 3f81be4751c73fb4
@pfn
pfn / 01 - iota dsl sample.scala
Last active September 1, 2016 22:25
sample of a strongly typed layout dsl for android results in http://i.imgur.com/KS7KLR6.png
package iota.sample
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.graphics.drawable.Animatable
import android.widget._
import android.view.ViewGroup.LayoutParams._
import iota._
class MainActivity extends AppCompatActivity { self =>
object Foo {
import Listeners.IotaExtensionMaterializers._
val view = new View(null)
val text = new TextView(null)
text.onClick { () }
text.onClickEx { view => "" }
text.onTextChange { () }
text.onTouchEx { (a, b) => true }
text.onTouch { true }
@pfn
pfn / viewHolders.scala
Last active July 12, 2016 21:02
generated viewholders for android layouts
package com.hanhuy.android.keepshare
import android.app.Activity
import android.view.{LayoutInflater, View, ViewGroup}
trait TypedViewHolder[T <: View] {
val rootViewId: Int
val rootView: T
}
@pfn
pfn / client.py
Last active April 11, 2016 21:48
sbtsimpleserver
#!/bin/env python
import socket
import sys
from sys import argv
from os import getcwd
if len(argv) < 2:
print "Usage: client <command>"
sys.exit(-1)
@pfn
pfn / facepreview.java
Created April 7, 2016 16:05
messing around with opencv
package com.hanhuy.android.vision;
import android.app.Activity;
import android.graphics.*;
import android.media.Image;
import android.os.Bundle;
import android.view.*;
import android.widget.FrameLayout;
import java.io.File;
def newSlider(state: PasswordGeneratorModel, labelres: Int, label: TextView, countRes: Int,
slider: SeekBar, enableTransform: (PasswordGeneratorModel, Boolean) => PasswordGeneratorModel,
isEnabled: PasswordGeneratorModel => Boolean, min: PasswordGeneratorModel => Int,
updateMin: (PasswordGeneratorModel,Int) => PasswordGeneratorModel,
seek1: SeekBarInfo, seek2: SeekBarInfo) = {
val ll = new LinearLayout(getActivity)
val cb = new CheckBox(...)
cb.setLayoutParams(stdH)
cb.setText(labelRes)
cb.setChecked(isEnabled(state)
IO(numSlider) >>= stdH >>= k.max(state.length) >>= k.progress(state.minNum) >>= k.enabled(state.num) >>=
hookM.seekBarChange.onProgressChanged((sb: SeekBar, p: Int, user: Boolean) => for {
st <- transformState(_.copy(minNum = p))
_ <- IO(minNumLabel) >>= k.text(getString(R.string.minimum_numbers, p.asInstanceOf[Integer]))
_ <- IO(uppSlider) >>= k.progress(math.min(st.minUpper, math.max(st.length - st.minNum - st.minSym, 0)))
_ <- IO(symSlider) >>= k.progress(math.min(st.minSym, math.max(st.length - st.minUpper - st.minNum, 0)))
} yield ()),