Navigation Menu

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 / lolpaypal.txt
Created November 26, 2013 03:20
Lol, paypal's short message is longer than the long message.
DoExpressCheckoutPayment failed:
{
'ACK': 'Failure',
'TIMESTAMP': '2013-11-26T03:18:22Z',
'L_SEVERITYCODE0': 'Error',
'L_SHORTMESSAGE0': 'Transaction refused because of an invalid argument. See additional error messages for details.',
'L_LONGMESSAGE0': 'A successful transaction has already been completed for this token.',
...
}
@sirpengi
sirpengi / gist:7536374
Created November 18, 2013 22:16
youtube's awesome error message
500 Internal Server Error
Sorry, something went wrong.
A team of highly trained monkeys has been dispatched to deal with this situation.
If you see them, show them this information:
q8tvTqOwLT5ji9a9wG0Llddj-MDpqyJ1XouR3hxmRuTNbNcu_KX36T9aJ2fw
iI0gqMVvBdrg-N1MWH8UZazCKQlx2BQ-Q8c356TX-pioVoQgyfyHoLcvHJOn
7Va6HYO_aRWC0Y1oYX1ael5_BrqOBS-G87TTPZijllTyuswFiilV20k9ICve
@sirpengi
sirpengi / diagonal-sum.clj
Created September 13, 2013 20:21
diagonal sum in clojure
(ns diagonal-sum)
(defn ds-step [[v prev step]]
[(+ v (* 4 prev) (* 10 step)) (+ prev (* 4 step)) (+ step 2)])
(defn ds-seq []
(map first (iterate ds-step [1 1 2])))
(println (take 10 (ds-seq)))
{
"v": 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
}
@sirpengi
sirpengi / blah.output
Created July 15, 2013 00:45
perl-yaml
[root@crap log]# yum search yaml | grep -i perl
perl-CPAN-Meta-YAML.noarch : Read and write a subset of YAML for CPAN Meta files
perl-Test-YAML-Valid.noarch : Lets you test the validity of YAML files in unit
perl-YAML.noarch : YAML Ain't Markup Language (tm)
perl-YAML-Parser-Syck.i686 : Perl Wrapper for the YAML Parser Extension: libsyck
perl-YAML-LibYAML.i686 : Perl YAML Serialization using XS and libyaml
perl-YAML-Syck.i686 : Fast, lightweight YAML loader and dumper
perl-YAML-Tiny.noarch : Read/Write YAML files with as little code as possible
perl-Test-CPAN-Meta-YAML.noarch : Validate a META.yml file within a CPAN
perl-Test-YAML-Meta.noarch : Validation of the META.yml file in a distribution
@sirpengi
sirpengi / randombot.gridlang
Last active December 15, 2015 01:19
randombot
@LOOPSTART
PUSH @MOVE
RAND << 3
ADD << 1
PUSH 2
CALLFF
POP
GOTO << @LOOPSTART