Skip to content

Instantly share code, notes, and snippets.

View TayKangSheng's full-sized avatar

Tay Kang Sheng TayKangSheng

View GitHub Profile
@TayKangSheng
TayKangSheng / record.sh
Created January 20, 2023 14:55
PinePhone record video with rear camera
#!/bin/ash
# Credits to Kevin Kofler
# https://forum.pine64.org/showthread.php?tid=16539&pid=109333#pid109333
if [ -z "$1" ] ; then
echo "usage: ./record.sh videoname"
exit 1
fi
@TayKangSheng
TayKangSheng / fizz_buzz.rb
Created November 29, 2020 10:13
cyber-dojo.org - FizzBuzz
require "rspec/autorun"
class FizzBuzz
def call
end
end
describe FizzBuzz do
let(:subject) { FizzBuzz.new }
@TayKangSheng
TayKangSheng / basicApplication.elm
Last active October 5, 2020 15:40
Browser.application template
module Site exposing (..)
import Browser exposing (Document, UrlRequest)
import Browser.Navigation exposing (Key)
import Url exposing (Url)
type alias Flags =
{}
@TayKangSheng
TayKangSheng / new_rails_app.txt
Last active August 8, 2020 16:40
basic steps for starting a new rails app
# starting a new rails app
# - use minitest
# - use postgresql
rails new MyApp --database=postgresql
# install helpful gems
bundle add slim-rails
bundle add shoulda-context -g test
bundle add shoulda-matchers -g test
@TayKangSheng
TayKangSheng / enumerator.rb
Last active April 16, 2020 15:44
How to create your own Ruby Enumerator
# Enumerator is a very powerful feature if you know how to use it. The most
# powerful part of Enumerator is the possibility of chaining them. Take some
# time to understand the intricacies of it because it is not very well
# documented. Some awesome references that I found are listed below. Note that
# I didn't understand when reading any of them right off the bat. Read a few,
# dig some documentation and experiment for yourself to get the "fuller"
# picture.
#
# [1]: https://blog.arkency.com/2014/01/ruby-to-enum-for-enumerator/
# [2]: https://stackoverflow.com/a/9194052
@TayKangSheng
TayKangSheng / JSON-to-Object.js
Last active March 5, 2020 07:11
Converting JSON to JavasScript Object
/*
Converting JSON file
{
"one": "1",
"two": "2"
}
to JavaScript Object
{
one: "1",
# start a shell inside the image
docker run -it -e ENV1=VALUE1 image-name:image-tag /bin/sh
@TayKangSheng
TayKangSheng / graphql-client.rb
Last active May 14, 2019 09:24
graphql-client
require "graphql/client"
require "graphql/client/http"
require "pry"
module GitHub
HTTP = GraphQL::Client::HTTP.new("https://api.github.com/graphql") do
def headers(context)
{ "Authorization": "Bearer #{ENV['personal_access_token']}" }
end
end
@TayKangSheng
TayKangSheng / rails-gem-builder.rb
Created February 12, 2018 05:25
Bootstrap gem creation for rails application
# The purpose is to create a Gem that has a dummy rails application and uses RSpec as the test framework.
# Check whether gem name is given.
if ARGV.length != 1
puts "ERROR: We need exactly one parameter. The name of a gem. Eg. MyGem"
exit;
end
# Initializing dependencies and utilities
require 'active_support/inflector'