Skip to content

Instantly share code, notes, and snippets.

View tony-garcia's full-sized avatar

Tony Garcia tony-garcia

View GitHub Profile
@paularmstrong
paularmstrong / pre-commit
Created November 25, 2010 20:43
Pre-Commit Hook for Git to add the SHA to a file in your working directory.
#!/usr/bin/env node
var child_process = require('child_process'),
fs = require('fs'),
root = __dirname + '/../../',
configFile = root + 'config/config.js',
jslint = require(root + 'lib/jslint/jslint.js');
function setPushVersion() {
child_process.exec('git rev-parse HEAD', { cwd: root }, function (error, stdout, stderr) {
@patrobinson
patrobinson / .bashrc
Last active July 11, 2021 23:03
aws vault bash profile
function aws-code() {
ykman oath -s bastion-account
}
function aws-vault-exec() {
local role_name=$1
export AWS_ACCOUNT=$role_name
shift
local command=$@
local extra_args=""
@arobson
arobson / abstractions.md
Last active October 14, 2021 06:46
Rabbit.MQ + Node.js Notes

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription
@kottenator
kottenator / djrf-error-parser.js
Last active April 15, 2022 13:49
JS error parser for django-rest-framework
/**
* Specific error parser for django-rest-framework errors structure
* Tested on django-rest-framework v2.3.13
* Live example at http://jsbin.com/wiqumo
*
* Error structure examples:
*
* // The most simple case
* { detail: "Authentication is required" }
*
@stolinski
stolinski / providerCompose.js
Created April 23, 2019 17:40
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}
@wehappyfew
wehappyfew / ssh-config-github-multiple-deploy-keys
Created September 29, 2016 13:10
Using multiple github deploy keys from a Jenkins instance
# When using a CI server, like Jenkins, in conjunction with github, you may wish to use
# multiple deploy keys (github-speak for an rsa key pair that has been assigned to a single
# repo, rather than a user) to allow Jenkins to pull code from the github repositories
# In the example here, where three repos are used, the idea is to take advantage of ssh's config mechanism
# For use with Jenkins, do the following:
# login to your CI Server
sudo su jenkins
cd ~/.ssh/
@epicserve
epicserve / example_command.py
Created October 30, 2013 17:05
Example of how to setup logging for a Django management command.
from django.core.management.base import BaseCommand
from mymodule import main
import logging
class Command(BaseCommand):
help = 'Do foo'
def handle(self, *args, **options):
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@phred
phred / pedantically_commented_playbook.yml
Last active November 3, 2023 01:55
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@lsauer
lsauer / InChi.js
Created October 25, 2011 14:13
Regular Expressions for validating SMILES, InChi, InChiKey
// International Chemical Identifier Regex, by lo sauer - lsauer.com
// Morphine InchI:
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1"
// applying an organic character-subset
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..)
!!x.trim().match(/^((InChI=)?[^J][0-9BCOHNSOPrIFla+\-\(\)\\\/,pqbtmsih]{6,})$/ig)
>true
//generic:
x.trim().match(/^((InChI=)?[^J][0-9a-z+\-\(\)\\\/,]+)$/ig)