Skip to content

Instantly share code, notes, and snippets.

View geminiyellow's full-sized avatar
🌴
On vacation

geminiyellow geminiyellow

🌴
On vacation
View GitHub Profile
@geminiyellow
geminiyellow / foo.tsx
Created April 10, 2020 02:58 — forked from OliverJAsh/foo.tsx
TypeScript React HOC using `forwardRef`
import * as React from 'react';
import { Component, ComponentClass, createRef, forwardRef, Ref } from 'react';
const myHoc = <ComposedComponentProps extends {}>(
ComposedComponent: ComponentClass<ComposedComponentProps>,
) => {
type ComposedComponentInstance = InstanceType<typeof ComposedComponent>;
type WrapperComponentProps = ComposedComponentProps & {
wrapperComponentProp: number;
@geminiyellow
geminiyellow / introrx.md
Created April 28, 2016 11:27 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@geminiyellow
geminiyellow / backbutton close bootstrap modal
Created March 1, 2016 12:46 — forked from thedamon/backbutton close bootstrap modal
Cause back button to close Bootstrap modal windows
$('div.modal').on('show', function() {
var modal = this;
var hash = modal.id;
window.location.hash = hash;
window.onhashchange = function() {
if (!location.hash){
$(modal).modal('hide');
}
}
});
@geminiyellow
geminiyellow / xhrpool.js
Created December 15, 2015 11:37 — forked from valerysntx/xhrpool.js
xhrPool - extendable async xml requests pool, with sequent callbacks per xhr
// xhrPool - async xml requests pool, with sequent callbacks per xhr
//
$.xhrPool = [];
$.xhrPool.callbacks = [];
$.xhrPool.starthandlers = [];
$.xhrPool.onEnd = function (name, obj, opts) {
@geminiyellow
geminiyellow / capybara cheat sheet
Created October 1, 2015 03:08 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@geminiyellow
geminiyellow / gist:b27e5b6600e1f4fe5a3a
Last active September 4, 2015 05:24 — forked from danielgtaylor/gist:0b60c2ed1f069f118562
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio

@geminiyellow
geminiyellow / Singleton.js
Last active August 29, 2015 14:27 — forked from you-think-you-are-special/Singleton.js
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: alexander@codeordie.ru
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
This document is outdated.
You should read David Bryant Copeland's excellent online book: http://angular-rails.com/crud_recipe.html
---------------------------------------------------------------------------------------------------------------
I think it's better to install javascript/css libraries using Bower rather than gem which is Ruby packager.
1. Install Rails 4 and create a new project.
2. Install bower(Note you need to install node first.)
sudo npm install -g bower
From http://linux.die.net/man/3/strftime
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%e - Day of the month without leading 0 (1..31)
%g - Year in YY (00-99)
@geminiyellow
geminiyellow / app.js
Last active August 29, 2015 14:20 — forked from krtek/app.js
angular.module('app', ['ngRoute', 'app.core', 'app.user', 'app.settings'])
.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/home', {
templateUrl: 'partials/home.html',
controller: 'HomeCtrl'
});
//Handle all exceptions
$routeProvider.otherwise({
redirectTo: '/home'