This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns testing.core | |
(:require-macros [cljs.core.async.macros :refer [go alt!]]) | |
(:require [cljs.core.async :refer [<! take! chan close! put! go-loop >!] :as async]) | |
(:require ["child_process" :refer [spawn]])) | |
(defn done-message? [message] | |
(and | |
(vector? message) | |
(= (message 0) :done))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replaces repetitive memoization syntax: | |
# ``` | |
# def foo | |
# return @_foo if defined? @_foo | |
# @_foo = 'bar' | |
# end | |
# ``` | |
# | |
# Usage: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// https://60devs.com/executing-js-code-with-nodes-vm-module.html | |
var code = ` | |
// global script scope | |
function nop() { | |
}; | |
var i = 1000000; // global script scope | |
while (i--) { | |
nop(); // access global scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { matchPattern } from "react-router/lib/PatternUtils"; | |
import { zipObject } from "lodash"; | |
const matchedPattern = matchPattern("/receipts/:id/inspect", location.pathname) | |
const params = zipObject(matchedPattern.paramNames, matchedPattern.paramValues) | |
console.log(params); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Adaptor = { | |
foo: function(message) { | |
console.log(message); | |
}, | |
bar: function() { | |
return 'baz' | |
} | |
} | |
function getHandlers(adaptor) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// request('GET',url) | |
// .then(console.log.bind(console)) | |
// .catch(console.error.bind(console)); | |
var request = function (verb,url,data) { | |
return new Promise(function (resolve,reject) { | |
var stateChange = function (xhr) { | |
request = xhr.target; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController < ApplicationController | |
protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' } | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NoTransactionBlock | |
module Nothing | |
def nothing | |
puts "CALLED" | |
end | |
end | |
module MigrationHelpers | |
def without_transaction_block(&block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = File.open(File.expand_path("~/Desktop/output.kml"), "w") | |
file.write <<-EOL | |
<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://www.opengis.net/kml/2.2"> | |
<Document> | |
EOL | |
CSV.foreach(File.expand_path('~/Desktop/***.csv'), col_sep: ";", headers: true) do |row| | |
file.write <<-EOL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form_for(@user, :validate=>true) do |f| | |
= f.label :birthdate | |
= f.date_select :birthdate | |
= f.text_field :birthdate, :type=>"hidden", 'data-validate'=>true | |
end | |
NewerOlder