Skip to content

Instantly share code, notes, and snippets.

View atesgoral's full-sized avatar

Ateş Göral atesgoral

View GitHub Profile
Verifying that +atesgoral is my blockchain ID. https://onename.com/atesgoral
@atesgoral
atesgoral / 1-original.js
Last active March 6, 2016 00:19
Syntactical sugar experiments against promise indentation hell
return getFoo()
.then(foo => {
return getBar(foo)
.then(bar => {
return getBaz(foo, bar)
.then(baz => {
return getQux(foo, bar, baz);
});
});
});
@atesgoral
atesgoral / github_totp.js
Created April 22, 2016 23:46
GitHub TOTP token generation
const GitHubApi = require('github');
const speakeasy = require('speakeasy');
github.authenticate({
type: 'basic',
username: process.env.GITHUB_USERNAME,
password: process.env.GITHUB_PASSWORD
});
const token = speakeasy.totp({
Verifying my Blockstack ID is secured with the address 1PZj88MLiKCR86H8JiSgu2e26fxpR17Rht https://explorer.blockstack.org/address/1PZj88MLiKCR86H8JiSgu2e26fxpR17Rht
@atesgoral
atesgoral / keybinding.json
Last active April 23, 2020 04:06
Visual Studio Code custom task for running current MiniTest
{ "key": "shift+ctrl+t", "command": "workbench.action.tasks.runTask", "args": "Run current MiniTest" }
module SofterDeleteAllDependents
extend ActiveSupport::Concern
included do
before_destroy :softer_delete_associations, prepend: true
end
private
def softer_delete_associations
@atesgoral
atesgoral / validate_upc.js
Last active July 5, 2019 14:32
UPC-12 validation
['101010101012','614141000036','036000241457','613119000030','614141000035','036000241450','614141000030']
.map(upc=>!(upc.split``.reduce((u,p,c)=>u+p*(3+c*2&3),0)%10))
// [true, true, true, true, false, false, false]
@atesgoral
atesgoral / sensitive.rb
Created November 12, 2020 02:28
A way to prevent accidental leaking of sensitive data
class Sensitive
@@being_responsible = false
def initialize(value)
@value = value
end
def to_s
@@being_responsible ? @value : '[REDACTED]'
end