Skip to content

Instantly share code, notes, and snippets.

View chengscott's full-sized avatar

Scott Cheng chengscott

View GitHub Profile
@chengscott
chengscott / random.h
Created December 15, 2019 10:05 — forked from Leandros/random.h
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
@chengscott
chengscott / pyc.py
Created July 20, 2019 09:45 — forked from jserv/pyc.py
import atexit
import ctypes
import os
import shlex
import sys
import tempfile
CMD_C_TO_SO = '{compiler} -shared -o {output} {input} {libraries}'
@chengscott
chengscott / git-subdirectory-tracking.md
Created July 19, 2019 08:30 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@chengscott
chengscott / pokemon.json
Last active April 22, 2016 15:59 — forked from shri/pokemon.json
JSON of pokemon to go with my pokemonMoves.json file
{
"1":{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",
@chengscott
chengscott / Connectivity.java
Last active August 29, 2015 14:26 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
package com.emil.android.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* Check device's network connectivity and speed
* @author emil http://stackoverflow.com/users/220710/emil
@chengscott
chengscott / FadeInNetworkImageView.java
Last active August 29, 2015 14:26 — forked from benvd/FadeInNetworkImageView.java
Extension of Volley's NetworkImageView that fades in images as they're loaded
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.*;
import android.util.AttributeSet;
import com.android.volley.toolbox.NetworkImageView;
public class FadeInNetworkImageView extends NetworkImageView {
private static final int FADE_IN_TIME_MS = 250;