Skip to content

Instantly share code, notes, and snippets.

Avatar

Ng Chen Hon (Mutatedbread) MutatedBread

View GitHub Profile
@MutatedBread
MutatedBread / rails-routes-practice.md
Created May 23, 2019
Writing down rails resource route in namespace practice.
View rails-routes-practice.md
namespace :admin do
  resources :articles, :comments
end
  1. index
  • admin_articles_path
  • admin_articles_url
@MutatedBread
MutatedBread / use-pointer-or-value.md
Last active May 20, 2019
A note on using pointer or value receiver in a golang function.
View use-pointer-or-value.md
func (s *MyStruct) pointerMethod() { } // method on pointer
func (s MyStruct)  valueMethod()   { } // method on value
  1. Receiver behaves like an argument given to a function.
  2. Perserve consistency for a struct, if use pointer, use pointer for all, vise versa.

Use Pointer

  1. Function needs to modify the receiver
@MutatedBread
MutatedBread / some-gsutil-useful.md
Last active Apr 7, 2019
Some useful gsutil commands
View some-gsutil-useful.md

Some useful gsutil Commands

Make bucket

gsutil mb gs://new_bucket/

Upload

View RN-bundleasset.md

Bundle Assets and Script

react-native bundle --assets-dest ./android/app/src/main/res/ --entry-file ./index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --platform android --dev false

View helloworld-box2d.cpp
#include <iostream>
#include <iomanip>
#include <Box2D/Box2D.h>
using namespace std;
int main()
{
//Construct a b2World
b2Vec2 gravity(0.0f, -10.0f);
@MutatedBread
MutatedBread / foobar_3.py
Last active Apr 3, 2017
Foobar challenge : gear_on_destruction. My answer spent 3 days of weekend thinking. It can get 7 test cases out of 10 correct only. Use for reference only. I am too lazy to comment on the code for the moment.
View foobar_3.py
from decimal import *
from fractions import Fraction
def answer(pegs):
# your code here
distance = []
radiusSampleSet = []
radius = [-1, -1]
@MutatedBread
MutatedBread / COVER_LETTER_EXAMPLE.md
Last active Jan 2, 2017
Application/Cover Letter Example
View COVER_LETTER_EXAMPLE.md

###Xiao Ming
Kuala Lumpur, Malaysia | +60123456789 | xiaoming@example.com


January 2, 2017

Supermegaultracoder Inc Human Resource Manager

999 Jalan Pisang,