Skip to content

Instantly share code, notes, and snippets.

View sirpengi's full-sized avatar

shu.chen sirpengi

View GitHub Profile
@sirpengi
sirpengi / main.dart
Created October 19, 2023 09:53
Implicit animation states in flutter
// Test project with a ListView.builder where the items have an
// implicit animation widget (this case an AnimatedContainer, in zulip-flutter
// for unread-markers we're using AnimatedOpacity) and the length
// of items sent into the ListView are changing. This simulates in ZF
// where we have start and end markers that are dynamically added/removed.
// The addition of a 'mark as read' marker at the beginning of the list
// cause most animations to lose their state (and thus no longer animated, but
// immediately transitioned to their new state).
//
// This test project solves that by giving the items a unique key and
@sirpengi
sirpengi / main.dart
Created July 19, 2023 17:08
Flutter scroll testing
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final ScrollController scrollEndController = ScrollController();
@sirpengi
sirpengi / blah.py
Created August 2, 2017 04:21
cached requests
from datetime import datetime, timedelta
from os import stat, unlink
import requests
import vcr
CFILE = "blah.cassette"
TTL = timedelta(minutes=15)
try:
cstat = stat(CFILE)
@sirpengi
sirpengi / keybase.md
Created February 9, 2017 00:36
keybase.md

Keybase proof

I hereby claim:

  • I am sirpengi on github.
  • I am sirpengi (https://keybase.io/sirpengi) on keybase.
  • I have a public key whose fingerprint is DD4A 1501 C3EA 961E F29D 6CE0 8043 C5BD 77C3 C053

To claim this, I am signing this object:

@sirpengi
sirpengi / blah.js
Created February 12, 2015 21:42
what is this
var evaluate = function(f) {
var args = copyArgs(arguments, 1)
if (_.isFunction(f)) {
return f.apply(f, args);
}
return f
};
@sirpengi
sirpengi / yolodb.py
Created September 27, 2014 18:23
yolodb
class YOLODBType(object):
pass
def YOLODB():
class val():
v = None
def _T(f, c, g, is_root=False):
class T(YOLODBType):
def __str__(self):
return str(g.v)
@sirpengi
sirpengi / saml.py
Created September 25, 2014 20:38
for saml
import time
def cry():
print "T.T;"
time.sleep(1)
T = type('T', tuple(), {'__getattr__': lambda s, k: cry()})()
lonely = True
while lonely:
@sirpengi
sirpengi / lol.js
Created September 4, 2014 22:28
wtf javascript
var assert = require("assert");
assert.equal(
({lol: 'LOL', javascript: 'JAVASCRIPT'})['lol', 'wtf', 'javascript'],
"JAVASCRIPT"
);
assert.equal(
({lol: 'LOL', javascript: 'JAVASCRIPT'})[['javascript']],
"JAVASCRIPT"
@sirpengi
sirpengi / fsm_test.js
Last active August 29, 2015 14:05
sample usage of backbone-fsm
module.paths.push(".");
var assert = require("assert");
var _ = require("underscore");
var Backbone = require("backbone");
var FSM = require("backbone-fsm").BackboneFSM;
/* Implementation of a turnstile (i.e., at train station). Turnstile is
initially locked and won't let people through. Once a coin is
inserted, the turnstile becomes unlocked, and lets one person through before
@sirpengi
sirpengi / touch.js
Created July 18, 2014 22:41
emulate touch event
// go to http://patrickhlauke.github.io/touch/tests/event-listener.html
el = document.getElementsByClassName("button")[0];
e = new Event("touch");
e.initEvent("touchstart", true, true);
el.dispatchEvent(e);