Skip to content

Instantly share code, notes, and snippets.

View taras's full-sized avatar

Taras Mankovski taras

View GitHub Profile
@taras
taras / task-lifting.js
Created July 19, 2019 17:41 — forked from cowboyd/task-lifting.js
What is the relationship between tasks and execution trees?
import { execute, call } from 'effection';
// One of the things that struck me was that when I was doing the
// implementation for the `enqueue` function in the task constraining
// functions
// (https://gist.github.com/cowboyd/19122da0c59c674cdea86cf6d70e9c75),
// was the eventual form it took.
//
// Like the other task constructors, it returned a function. Let's
@taras
taras / react-event-pipeline.jsx
Created August 6, 2018 17:18 — forked from cowboyd/react-event-pipeline.jsx
Hypothetical React Event Pipeline
import { pipe as $, string, preventDefault, blockOn } from 'react-event-pipeline'
function onSubmit(form) {
return $(preventDefault, blockOn(() => form.isSubmittable), onSave(form.serialized));
}
export default function Settings({ flares, knotsPerFlare, onSave }) {
return (
<State type={Form} value={{ flares, knotsPerFlare }}>
{form => {
import Ember from 'ember';
export default Ember.Controller.extend({
myService: Ember.inject.service('my-service'),
appName: 'Ember Twiddle'
});
@taras
taras / redirect-to-www.php
Last active July 13, 2016 19:07 — forked from mikeschinkel/redirect-to-www.php
MU-Plugin for WordPress to redirect from non-www to www domain
<?php
if ( ! preg_match( '#wp-json#', $_SERVER['REQUEST_URI'] ) && ! preg_match( '#wp-content#', $_SERVER['REQUEST_URI'] ) && ! preg_match( '#^www.#', $_SERVER['HTTP_HOST'] ) ) {
$https = 443 === $_SERVER['SERVER_PORT'] ? 's' : '';
header( "Location: http{$https}://www.{$_SERVER['HTTP_HOST']}", true, 301 );
die();
}
@taras
taras / application.controller.js
Last active December 23, 2015 03:51 — forked from ZackMattor/application.controller.js
finalizeQueryParamChange - With A solution
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['test'],
appName:'finalizeQueryParamChange bug example',
actions: {
set_param() {
this.set('test', 'foo');
}
attributes relationships
parent
data
type id
parents
1
@taras
taras / README.md
Last active October 13, 2015 21:08 — forked from Integralist/git apply gist diff.sh
Stash a `git diff` to gist to abort an upgrade but not loose your progress

Not every Ember upgrade goes as planned. Back out - to fight another day, by stashing your WIP to a Gist.

Installation

gem install gist

Login

gist --login

Send a diff to gist

git diff | gist -p -f wip-upgrade.diff # -> returns a url, save the url to later restore your diff

@taras
taras / 0_reuse_code.js
Created February 2, 2014 23:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# So, this is pretty horrible. If we just encode using btoa, any UTF-8 chars cause an error.
# If we use either of the workarounds on MDN[1], the £ sign is encoded wrong. I suspect
# Excel totally sucking at encodings is the reason why. So, the workaround is, to use
# the MDN workaround on chars with values > 255, and allow chars 0-255 to be encoded
# as is with btoa. Note that if you use either of the workarounds on MDN, chars
# 128-255 will be encoded as UTF-8, which includeds the £ sign. This will cause excel
# to choke on these chars. Excel will still choke on chars > 255, but at least the £
# sign works now...
# [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
var empty, get, set,
__hasProp = {}.hasOwnProperty;
get = Ember.get;
set = Ember.set;
empty = function(obj) {
var key;
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;