Skip to content

Instantly share code, notes, and snippets.

@dameleon
dameleon / rx_sample_codes.md
Last active November 24, 2016 23:39
Dive to Reactive Extension with Swift サンプルコード
<div class="root-layerd">
<div class="layer-background">
<div style="background:url(path/to/background.png)"></div>
</div>
<div class="layer-contents-main">
<h2>タブ1</h2>
<ul>
<li><img></li>
<li><img></li>
<li><img></li>
function peco-git-branch-awesome () {
local selected_branch_name="$(git branch -a | peco | tr -d ' ')"
case "$selected_branch_name" in
*-\>* )
selected_branch_name="$(echo ${selected_branch_name} | perl -ne 's/^.*->\s(.*?)\/(.*)$/\2/;print')";;
remotes* )
selected_branch_name="$(echo ${selected_branch_name} | perl -ne 's/^.*?remotes\/(.*?)\/(.*)$/\2/;print')";;
esac
if [ -n "$selected_branch_name" ]; then
BUFFER="git checkout ${selected_branch_name}"
paw.js
======
## how to use
### simplest use
```
@dameleon
dameleon / env.js
Created October 7, 2014 09:24
create environment object for smartphone
function __getEnvData(ua) {
ua = ua.toLowerCase();
var appleWebkitRE = /applewebkit/;
var res = {
isAndroid : /android/.test(ua),
isIOS : /ip(hone|od|ad)/.test(ua),
isChrome : /(chrome|crios)/.test(ua),
versionString: null,
version: null
var view = new Backbone.View.extend({
str: 'hoge',
arr: [],
init: function() {}
});
// 全部 __proto__ に生える
view.__proto__.str; // -> hoge
view.__proto__.arr; // -> []
view.__proto__.init; // -> fn
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1">
<style>
</style>
</head>
<body>
<h2>sample1</h2>
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
function SomeClassOne() {
this.someClassTwoInstance = new SomeClassTwo(this);
}
SomeClassOne.prototype = {
foo: foo,
bar: bar,
};
function foo() {
@dameleon
dameleon / js
Last active December 29, 2015 07:49
;(function(global, document, undefined) {
function Hoge() {
// constructor
return this;
}
Hoge.prototype = {
constructor: Hoge,