Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
View GitHub Profile
@dexteryy
dexteryy / standards_for_webapps_on_mobile.md
Last active Aug 17, 2017
W3C Standards for Web Apps on Mobile (After HTML5)
View standards_for_webapps_on_mobile.md
@broerjuang
broerjuang / thinkingInReact.re
Created Feb 9, 2018
This is the implementation of thinking in react using reason
View thinkingInReact.re
type product = {
category: string,
price: string,
stocked: bool,
name: string
};
type products = list(product);
let products = [
@Zerim
Zerim / SignupForm.re
Last active Feb 19, 2018
A simple SignupForm written in ReasonML
View SignupForm.re
/* `action` and `state` types must be defined before the `let component` statement for type inference to work */
type action =
| UpdateEmail string
| UpdatePassword string;
type state = {
email: string,
password: string
};
@ChrisCinelli
ChrisCinelli / gist:2051841
Created Mar 16, 2012
Logging of Javascript error on the Frontend to the Backend
View gist:2051841
/* ==========================================================
*
* Log on a remote server most of the errors in the browser
*
* @author Chris Cinelli
*
* Depends on:
* stacktrace.js - https://github.com/eriwen/javascript-stacktrace
* jsonStringify.js - http://www.thomasfrank.se/json_stringify_revisited.html
*
View *tracked.md

tracked npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation

@danielphillips
danielphillips / UILabel+dynamicSizeMe.h
Created Jun 2, 2011
Adjust UILabel to change it's frame according to it's content
View UILabel+dynamicSizeMe.h
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@paullewis
paullewis / gist:1981455
Created Mar 5, 2012
Quicksort in JavaScript
View gist:1981455
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@alexfedoseev
alexfedoseev / 1-styles.css
Created Apr 18, 2017
CSS Modules + PostCSS + Webpack
View 1-styles.css
:root {
--my-width: 400px;
}
:export {
myWidth: var(--my-width);
}
.myClass {
width: var(--my-width);
@paul-delange
paul-delange / GIFDownloader.h
Created Nov 18, 2012
Convert remote GIF into something MPMoviePlayerController can use
View GIFDownloader.h
//
// GIFDownloader.h
// TheJoysOfCode
//
// Created by Bob on 29/10/12.
// Copyright (c) 2012 Tall Developments. All rights reserved.
//
#import <Foundation/Foundation.h>
@kendellfab
kendellfab / read_line.go
Created Nov 11, 2013
Golang --> Read file line by line.
View read_line.go
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
You can’t perform that action at this time.