Skip to content

Instantly share code, notes, and snippets.

Raising Dinos 🦖

Yangshun Tay yangshun

Raising Dinos 🦖
Block or report user

Report or block yangshun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
yangshun / DailyJS Tags Sorter
Created Feb 24, 2014
This snippet of code can be used to sort the posts within each tag category on the DailyJS site:
View DailyJS Tags Sorter
(function() {
$('.posts').each(function() {
var $postsInCat = $(this).children();
var $sortedCat = $postsInCat.sort(function(a, b) {
var dateA = new Date($(a).children('div').html());
var dateB = new Date($(b).children('div').html());
return dateA < dateB ? 1 : -1;
yangshun / Python Variable Scope Examples
Last active Aug 29, 2015
Python Variable Scope Examples
View Python Variable Scope Examples
a = 1
def foo():
print(a) # Prints 1. Accesses the variable a outside its own scope.
print(a) # Prints 1. a not modified.
b = 2
def bar():
yangshun / nus-timetabledatagenerator.js
Created Jun 30, 2014
Creating nus_timetable_data.js
View nus-timetabledatagenerator.js
var fs = require('fs');
var data = JSON.parse(fs.readFileSync('modules.json'));
var weeks = ['EVERY WEEK', 'ODD WEEKS', 'EVEN WEEKS'];
yangshun /
Created Nov 26, 2014
Demonstrate local, nonlocal, and global scope of variables
def scope_test():
def do_local():
spam = "local spam"
def do_nonlocal():
nonlocal spam
spam = "nonlocal spam"
def do_global():
global spam
spam = "global spam"
spam = "test spam"
yangshun /
Last active Aug 29, 2015
CS1020 Codes Autograder
# Assumes a directory structure of:
# dir
# |-- skeleton
# | |--
# | +-- (this file)
# |
# +-- testdata
# |-- input
View CS3217 Testing
Blackbox testing:
Test background loads ok and is scrollable
Still scrollable with game objects.
Test implementation of buttons
Save, load
Save/load empty screen
Save/load one object (try different types)
Save/load one object of each type
Save/load with many objects
View kolor-hack.js
// Hack for Kolor Game
// 1. Play the game at
// 2. Before clicking on "Start!", open up the JavaScript console and paste the following snippet of code.
// 3. WIN.
// Change the value for INTERVAL to have a faster refresh rate.
// Set AUTOPLAY to true to let the game play on its own, you lazy bum.
(function () {
View jQuery.touchScrollBuster.js
jQuery.touchScrollBuster v0.0.1
Tay Yang Shun
The MIT License (MIT)
Copyright (c) 2015
$(el).touchScrollBuster() will prevent parent containers from scrolling
when the child container is at the top or at the bottom.
yangshun / .eslintrc
Created Oct 22, 2015
An eslint configuration that I adhere to
View .eslintrc
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"arrowFunctions": true,
"blockBindings": true,
"generators": true
"rules": {
"accessor-pairs": 0,
yangshun / Enhance.js
Created Nov 1, 2015 — forked from sebmarkbage/Enhance.js
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
componentDidMount() {
this.setState({ data: 'Hello' });
render() {
You can’t perform that action at this time.