(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
function requireUncached(module) { | |
delete require.cache[require.resolve(module)]; | |
return require(module); | |
} |
// NOTE: make sure your engine supports tail-call optimization | |
function matchAll(re, text) { | |
return (function find(acc) { | |
const match = re.exec(text); | |
if (match) { | |
acc.push(match); | |
return find(acc); | |
} | |
return acc; | |
})([]); |
# find something that has more than one of something | |
Account.joins(:users).select('accounts.id').group('accounts.id').having('count(users.id) > 1') |
Sidekiq.redis { |conn| conn.flushdb } |
ActiveRecord::Base.connection.tables.collect{|table_name| ActiveRecord::Base.connection.execute("TRUNCATE #{table_name} RESTART IDENTITY")} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Adi</title> | |
<script src="http://yourjavascript.com/2223141713/purple-flower-effect-spiceupyourblog.js"> | |
</script> | |
<style type="text/css"> | |
#adi { | |
width:0px; | |
margin: 200px auto; |
Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.
Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.
First you will need to get an OAuth Token from GitHub using your own username and "note"
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
L.TileLayer.Common = L.TileLayer.extend({ | |
initialize: function (options) { | |
L.TileLayer.prototype.initialize.call(this, this.url, options); | |
} | |
}); | |
(function () { | |
require 'faraday' | |
require 'json' | |
URL = 'https://anggiaj.buddycloud.com/api' | |
conn = Faraday.new | |
conn.basic_auth 'thoriq@anggiaj.buddycloud.com', 'cencoredpassword' | |
res = conn.post "#{URL}/thoriq@anggiaj.buddycloud.com/content/posts", { content: 'Hello world' }.to_json, 'Content-type' => 'application/json' | |
# response body | |
{ |