Skip to content

Instantly share code, notes, and snippets.

View adjavaherian's full-sized avatar
✌️
💾 🔧 ⚾️

Amir Djavaherian adjavaherian

✌️
💾 🔧 ⚾️
View GitHub Profile
@jdx
jdx / boot.js
Last active August 11, 2024 13:00
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@fredrick
fredrick / App-example-test.js
Last active April 6, 2018 12:39
React Router Test Context Helper
var React = require('react/addons'),
TestUtils = React.addons.TestUtils,
TestContext = require('./TestContext'),
App = require('./App.jsx'),
app = TestContext.getRouterComponent(App);
describe('App', function() {
it('has something', function() {
expect(app.getDOMNode().textContent).toContain('something');
});
@adjavaherian
adjavaherian / Analytics.jsx
Last active December 13, 2017 15:33 — forked from fredrick/App-example-test.js
Here's how we have been pre-processing Jest tests for React.js components which require React-Router or Fluxxor.
//./app/modules/Analytics.jsx
var React = require('react');
var Fluxxor = require('fluxxor');
var FluxMixin = Fluxxor.FluxMixin(React);
var paths = require('../helpers/paths');
var Analytics = React.createClass({
displayName: 'Analytics',
mixins: [FluxMixin],
@fordprefect480
fordprefect480 / bot.js
Last active February 18, 2016 19:16
A slackbot which retrieves Star Wars articles given a search term.
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a simple Slack bot built with Botkit. The bot is called 'holocron' and will go get a Star Wars article (from Wookiepedia)
if you mention or direct mention the bot with a search term.
haproxy.conf:
http-request redirect location %[path,lower,map(/etc/haproxy/redirects-path.map)] code 301 if { path,lower,map(/etc/haproxy/redirects-path.map) -m found }
redirects-path.map:
/help /en/help/help.html
/sitemap /en/sitemap.xml
@drubin
drubin / cordon-drain-pool
Last active May 3, 2022 14:21
Cordon and Drain GKE Node pools
#!/bin/bash -e
# Cordons and drains a node pool
display_usage() {
echo "Cordons and drains a nodepool"
echo -e "\nUsage:\n ./cordon-drain-pool [nodepool-name] "
echo -e " ./cordon-drain-pool pool-1 \n"
}
if [ $# -le 1 ]
then