Skip to content

Instantly share code, notes, and snippets.

@qrush
qrush / application_job.rb
Last active March 31, 2020 01:38
Use Honeycomb to trace ActiveRecord calls inside of ActiveJob
class ApplicationJob < ActiveJob::Base
around_perform do |job, block|
Honeycomb.start_span(name: job.class.name) do |span|
span.add_field 'type', 'worker'
span.add_field 'queue.name', job.queue_name
block.call
end
end
end
@WeiChiaChang
WeiChiaChang / progress.html
Created July 26, 2017 10:08
Simple Pure CSS Progress Bar
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta chatset="UTF-8" />
<title>CSS Progress Bar</title>
<style>
.wrapper {
width: 500px;
}
@ziluvatar
ziluvatar / token-generator.js
Last active July 24, 2024 16:53
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@juliancoleman
juliancoleman / YakYak.desktop
Last active February 12, 2018 04:43
A concise install instruction for YakYak on Ubuntu GNOME 16.04
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Name=YakYak
Comment=Desktop client for Google Hangouts
GenericName=Hangouts Client
Exec=/opt/yakyak-linux-x64/yakyak
Icon=/opt/yakyak-linux-x64/resources/app/icons/icon@32.png
Terminal=false

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@zulhfreelancer
zulhfreelancer / starts_with.md
Created November 17, 2016 07:34
Rails ActiveRecord: How to find all items that starts with something?
Model.where("table_column LIKE :prefix", prefix: "#{keyword}%")
@Rich-Harris
Rich-Harris / footgun.md
Last active July 8, 2024 03:54
Top-level `await` is a footgun

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

// Correct Way
function indexOf(str, query) {
for(var i = 0; i < str.length; i++) {
for(var q = 0; q < query.length; q++) {
if (str[i+q] !== query[q]) {
break;
}
if (q === query.length - 1) {
return i;
}
@hilkeheremans
hilkeheremans / .drone.yml
Created April 28, 2016 11:13
Drone CI with nodejs, npm and private modules
# drone.yml for node js CI with npm login
# Don't forget to configure DRONE_SERVER and DRONE_SERVER
# Now create a secrets.yml (OUTSIDE of your repo!!) (see other file)
# then run drone secure --repo <drone_repo_name> --in <path>/secrets.yml
build:
unit_tests:
image: risingstack/alpine:3.3-v4.2.6-1.1.3
commands:
- npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
- npm install
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter