Skip to content

Instantly share code, notes, and snippets.

View yihyang's full-sized avatar
😰
kinda busy

Yih Yang yihyang

😰
kinda busy
View GitHub Profile
@yihyang
yihyang / golang_setup.md
Created December 14, 2017 04:08 — forked from sathiyaseelan/golang_setup.md
Basics to setup a golang project repo in your local

Simple Guide to setup Golang in your Mac and clone a repo.

Setup Go and workspace

Type go in terminal, to verify the installation.

  • Create a Go workspace and set GO PATH
@yihyang
yihyang / Responsive Spec Helpers With Meta tags
Created November 29, 2017 01:57 — forked from sathiyaseelan/Responsive Spec Helpers With Meta tags
Helpers for Responsive feature Specs in Capybara
The responsive helpers are to help the developer with writing responsive specs.
All you have to do is, add `responsive_helper.rb` to the spec support directory.
And tag the specs with :mobile, :tablet for mobile and tablet size respectively.
If you don't use any tag, it would render the desktop size.
@yihyang
yihyang / benchmark-ips.rb
Last active September 7, 2017 07:53
Simple ruby script to compare performance for different functions / methods
# using 'benchmark-ips' gem
# gem install benchmark-ips
require 'benchmark/ips'
require 'active_support/core_ext/string'
properties = { text: '123' }
n = 10_000_000
Benchmark.ips do |x|
x.report('try') { n.times { properties[:text].try(:html_safe) } }
@yihyang
yihyang / GIF-Screencast-OSX.md
Created August 18, 2017 07:57 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@yihyang
yihyang / scrollable-anchor.js
Created August 11, 2017 04:11
Make your anchor scrollable to Sections in HTML
$("button").click(function() {
$('html,body').animate({
scrollTop: $(".second").offset().top},
'slow');
});
@yihyang
yihyang / truffle.js
Created July 19, 2017 16:16
Truffle configuration
var DefaultBuilder = require("truffle-default-builder");
module.exports = {
build: new DefaultBuilder({
"index.html": "index.html",
"app.js": [],
"app.css": [],
"images/": ""
}),
networks: {
development: {
@yihyang
yihyang / Simple Bootstrap v4 alpha Boilerplate
Created July 19, 2017 14:56
Simple Bootstrap v4 Alpha Boilerplate for your instantaneous plug n play need!
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Boilerplate</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
@yihyang
yihyang / colored_terminal.MD
Last active July 3, 2017 06:07
Python Colored Terminal Output

Terminal Color

Having python to print output to terminals with different colors.

Execute

  • Place both files side by side and execute python test_print.py to see the result

Environment

# -*- coding: utf-8 -*-
import scrapy
import os.path
class DomainSpider(scrapy.Spider):
name = "domain"
allowed_domains = ["www.domain.com"]
max_num_of_page = 2
link = 'http://www.domain.com'
start_urls = []
@yihyang
yihyang / scrapy-example.py
Created August 15, 2016 05:10
Example of crawling websites from scrapy
import scrapy
import os.path
class EmailSpider(scrapy.Spider):
name = "test"
allowed_domains = ["test.com"]
start_urls = ['test.com/1', 'test.com/2']
# the spider will crawl according to the 'start_urls' available
def parse(self, response):