Skip to content

Instantly share code, notes, and snippets.

@jtryan
jtryan / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jtryan
jtryan / test.js
Last active August 29, 2015 14:18 — forked from Spoygg/test.js
describe('Test example.com', function(){
before(function(done) {
client.init().url('http://example.com', done);
});
describe('Check homepage', function(){
it('should see the correct title', function(done) {
client.getTitle(function(err, title){
expect(title).to.have.string('Example Domain');
done();
@jtryan
jtryan / README.md
Last active August 29, 2015 14:19 — forked from denji/README.md

Quick uninstall JetBrains settings:

curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s
@jtryan
jtryan / README.md
Last active August 29, 2015 14:20 — forked from denji/README.md

Quick uninstall JetBrains settings:

curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s
---------------------------------------------------------------------------------------------------
Turn off power down on time out
Turn off power down on lid close
$ sudo stop powerd
---------------------------------------------------------------------------------------------------
Open port 22 for ssh
$ sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
---------------------------------------------------------------------------------------------------
Set hostname
$ sudo hostname <new-hostname>
@jtryan
jtryan / StateSavingArrayAdapter.java
Created August 14, 2016 02:18 — forked from curioustechizen/StateSavingArrayAdapter.java
StateSavingArrayAdapter: An ArrayAdapter that knows how to save/restore its own state.
/**
* <p>
* An {@code ArrayAdapter} that also knows how to save and restore its state.
* Basically all it does is save/restore the array of objects being managed by
* the Adapter.
* </p>
*
* <p>
* Note that this only saves the items and not things like checked item
* positions. Those belong to the {@link ListView} itself. Consider using
@jtryan
jtryan / .bashrc
Created February 19, 2019 14:32 — forked from miguelmota/.bashrc
Show host IP address on your bash prompt.
# Show host IP address on your bash prompt.
#
# Example of prompt:
#
# moogs@192.168.1.100 : ~/Dropbox/workspace
# $
#
export PS1="\n\n\[\033[0;36m\]\u@$(ifconfig | grep "inet " | grep -v 127.0.0. | awk '{print $2}')\[\033[00m\]\[\033[0;32m\] : \w\[\033[00m\]\n\[\033[00;32m\]\$\[\033[00m\] "
export PS2="\[\033[0;32m\]>\[\033[00m\] "
@jtryan
jtryan / lambdaAMIBackups.py
Created February 5, 2021 17:04 — forked from bkozora/lambdaAMIBackups.py
AWS Lambda AMI Backups
# Automated AMI Backups
#
# @author Bobby Kozora
#
# This script will search for all instances having a tag with the name "backup"
# and value "Backup" on it. As soon as we have the instances list, we loop
# through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@jtryan
jtryan / filebeat-cloudtrail-s3-elasticsearch.json
Created June 30, 2022 20:52 — forked from vindimy/filebeat-cloudtrail-s3-elasticsearch.json
Cloudformation file that sets up Filebeat/Cloudtrail Elasticsearch forwarding (Cloudtrail writes to S3 bucket)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Elastic SIEM - Filebeat ingestion of Cloudtrail logs from S3",
"Parameters": {
"KeyPair": {
"Type": "AWS::EC2::KeyPair::KeyName",
"Default": "",
"Description": "Name of an existing EC2 KeyPair to enable SSH access"
},