Skip to content

Instantly share code, notes, and snippets.

enscript -f Source-Code-Pro8 --line-numbers -p - createPropTypes.js |pstopdf -i -o out.pdf
open out.pdf
@dseg
dseg / gist:995181a123e63cedb7f8629244cdd3e7
Last active October 14, 2016 04:52
How do I find the values to put into my typings.json?

typings/typings#603

typings info dt~PACKAGE_NAME --versions

** But you normally should not edit typings.json manually. ** It's definitely easier to just do

@dseg
dseg / Generate a 32-bytes base16 string
Created November 2, 2016 12:06
gen-32bytes-base16.sh
#!/bin/sh
dd count=1024 if=/dev/random 2>/dev/null|md5sum|cut -d' ' -f1
@dseg
dseg / get_stock_quotes_nintendo.sh
Created December 7, 2016 09:43
Get Stock Quotes from command-line (shell)
$ curl http://finance.google.com/finance/info?q=TYO:7974
// [
{
"id": "672774"
,"t" : "7974"
,"e" : "TYO"
,"l" : "27,980.00"
,"l_fix" : "27980.00"
,"l_cur" : "�27,980.00"
@dseg
dseg / confirm-dialog.tsx
Created December 15, 2016 12:48
stateless-function-component-in-typescript
import * as React from 'react';
interface IInquiryConfirmDialogProps {
message: string;
onClick?: (evt: any) => void;
}
const InquiryConfirmDialog: React.StatelessComponent<IInquiryConfirmDialogProps> = (props: IInquiryConfirmDialogProps) =>
<div className="modal-box">
<form>
@dseg
dseg / template-literal-1.ts
Created December 17, 2016 10:30
An ES6 Template Literal experiment
let tag = (strings, ...keys) => (...values) => {
//console.log(strings); // [ '', 'は', 'です。' ]
//console.log(keys); // [ 0, 1 ]
let dict = values[values.length - 1] || {};
let result = [strings[0]];
keys.forEach((key: any, i: number) => {
let value = Number.isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
return result.join('');
@dseg
dseg / tscc.sh
Created December 22, 2016 10:47
Compile and run a typescript file
function tscc {
local target
if [[ -n $2 ]]; then
target="$2"
else
target=es6
fi
tsc -t "$target" "$1" -outFile /dev/stdout | node
}
@dseg
dseg / base64_encode_decode.sh
Created January 5, 2017 06:24
Base64 Encode & Decode
#!/bin/bash
function b64enc {
# エンコード。-e は省略可。
if [[ -n $1 ]] && [[ -f $1 ]]; then
openssl enc -e -base64 "$1"
fi
}
function b64dec {
@dseg
dseg / select.tsx
Created January 27, 2017 06:32
A React Select Snippet
<select>
{
// options が undefined or nullなら、何も出力しない。配列なら選択肢に整形する。
options && Array.isArray(options) && options.map((item : any, idx : number) =>
<option
key={`inq_opt_${idx}`}
value={item.value}>{item.label}</option>)
}
</select>
@dseg
dseg / makeQueryString.ts
Created February 23, 2017 08:59
Crafting a query string from an array using ES6's template literal feature
/**
* Template String Tag (For crafting query-string for HTTP/Get from a array)
*
* Usage: qsTag`${['a','b','c','d']}`(); // a=b&c=d
*/
export const qsTag = (strings, ...keys) => (...values) => {
let result = [];
const input = keys[0];
input.forEach((key: any, i: number, ary: any[]) => {
const postfix = (ary.length-1 === i ? '' : '&');