Skip to content

Instantly share code, notes, and snippets.

View pengisgood's full-sized avatar
😕
What's next?

Max Peng pengisgood

😕
What's next?
View GitHub Profile
@pengisgood
pengisgood / fibonacci-generator.js
Created December 3, 2018 07:11
Calculate Fibonacci number with ES6 generator
const Fibonacci = function* (i = 1, j = 1) {
yield i;
yield j;
while (true) {
yield* Fibonacci(i + j, i + j + j);
}
};
const f = Fibonacci();
for (let i = 0; i < 20; i++) {
@pengisgood
pengisgood / checkstyle.xml
Created February 28, 2018 05:51
checkstyle 8.1 example
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
@pengisgood
pengisgood / build.gradle
Last active September 18, 2017 16:41
Return customized http status code
buildscript {
ext {
kotlinVersion = '1.1.4-3'
springBootVersion = '2.0.0.M4'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
class AddHeroImages < ActiveRecord::Migration
def change
{image_mime_type: nil, image_name: "carousel-image1.jpg", image_size: 1937453, image_width: 1830, image_height: 996, image_uid: "2014/12/15/17/37/48/423/carousel_image1.jpg", image_title: "MICS5_Photo_SurveyDesign_Workshop_Dakar_April_2013", image_alt: "MICS5_Photo_SurveyDesign_Workshop_Dakar_April_2013"},
{image_mime_type: nil, image_name: "carousel-image2.jpg", image_size: 1560842, image_width: 1830, image_height: 996, image_uid: "2014/12/15/17/42/42/113/carousel_image2.jpg", image_title: "MICS5_Photo_SurveyDesign_Workshop_Amman_April_2013", image_alt: "MICS5_Photo_SurveyDesign_Workshop_Amman_April_2013"},
{image_mime_type: nil, image_name: "carousel-image3.jpg", image_size: 1035076, image_width: 1830, image_height: 996, image_uid: "2014/12/15/17/44/39/205/carousel_image3.jpg", image_title: "MICS5_Kathmandu_SurveyDesign_March2013", image_alt: "MICS5_Kathmandu_SurveyDesign_March2013"}
Refinery::Image.create!(
image_mi