Skip to content

Instantly share code, notes, and snippets.

View kika's full-sized avatar

Kirill Pertsev kika

View GitHub Profile
@brantburnett
brantburnett / userdata.sh
Last active October 8, 2020 16:12
Couchbase EC2 NVMe Userdata Script
#!/bin/bash
# Include as user data during instance startup, or run as root using sudo
# Assumes that you are using an i3 instance type with NVMe instance storage attached
# Set swappiness to zero
sysctl vm.swappiness=0
echo "vm.swappiness = 0" >> /etc/sysctl.conf
# Disable transparent huge pages
cat > /etc/init.d/disable-thp <<- 'EOM'
@agentsim
agentsim / highsierra_bootable.sh
Created June 10, 2017 02:23
Create bootable ISO from HighSierra Installer
# Generate a BaseSystem.dmg with 10.13 Install Packages
hdiutil attach /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -mountpoint /Volumes/highsierra
hdiutil create -o /tmp/HighSierraBase.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierraBase.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
cp -R /Volumes/highsierra/Packages /Volumes/OS\ X\ Base\ System/System/Installation
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/highsierra/
mv /tmp/HighSierraBase.cdr.dmg /tmp/BaseSystem.dmg
@mjackson
mjackson / resolvePromise.js
Last active September 9, 2018 08:23
An easy way to do async APIs in JavaScript that support both promises *and* callbacks!
// Here is a function that I use all the time when creating public
// async APIs in JavaScript:
const resolvePromise = (promise, callback) => {
if (callback)
promise.then(value => callback(null, value), callback)
return promise
}
// Sometimes I like to use callbacks, but other times a promise is
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@kofno
kofno / README.markdown
Last active January 26, 2016 23:03
Parsing AWS JSON w/ Purescript

Paring AWS JSON w/ PureScript

I'm experimenting with parsing AWS JSON with purescript.

Given the Data.JSON.S3 module provided, here's what I see in the console:

$> eitherDecode "{ \"Records\": [{ \"s3\": { \"bucket\": { \"name\": \"foo\"}, \"object\": { \"key\": \"bar.png\" } } } ] }" :: Either String Records
@lox
lox / cloudformation_tail.sh
Created August 3, 2015 04:08
A bash script to tail CloudFormation events
#!/bin/bash -eu
# Show all events for CF stack until update completes or fails.
cf_tail() {
local stack="$1"
local current
local final_line
local output
local previous
until echo "$current" | egrep -q "${stack}.*_(COMPLETE|FAILED)" ; do
@puffnfresh
puffnfresh / CGSSpaces.h
Last active February 20, 2023 17:57
Header for undocumented Spaces APIs
#include <Carbon/Carbon.h>
typedef void *CGSConnectionID;
extern CGSConnectionID _CGSDefaultConnection(void);
#define CGSDefaultConnection _CGSDefaultConnection()
typedef uint64_t CGSSpace;
typedef enum _CGSSpaceType {
kCGSSpaceUser,
kCGSSpaceFullscreen,
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@bobthecow
bobthecow / tab.bash
Last active November 10, 2023 08:47
Open new Terminal tabs from the command line
#!/bin/bash
#
# Open new Terminal tabs from the command line
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc`
#