Skip to content

Instantly share code, notes, and snippets.

@christopherdeutsch
christopherdeutsch / upgrade.sh
Last active January 6, 2023 03:06
Upgrade a Cassandra node
#!/bin/bash
#
# Upgrade a node
#
cassandra_config="/etc/cassandra/cassandra.yaml"
echo "Taking snapshot..."
nodetool -h localhost snapshot
@taogawa
taogawa / Enumerable.cs
Created May 25, 2013 11:09
Edulinq Part2:Whereまで
using System;
using System.Collections.Generic;
namespace Edulinq
{
public static partial class Enumerable
{
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
if (source == null)
@tonylukasavage
tonylukasavage / script.sh
Created May 29, 2013 18:18
Move all uncommitted changes to a new branch and revert the existing branch to HEAD. "master" has uncommitted changes. You decided you'd rather make those changes in "dev_branch". Here's how to move those uncommitted changes to "dev_branch" and then revert "master" to its last commit.
# get into the master branch
git checkout master
# create a new branch for the changes and check it out
git checkout -b dev_branch
# stash the changes until we revert master
git stash
# go back to master
@sumanth232
sumanth232 / mytemplate.cpp
Last active May 2, 2020 04:03
All the #defines, typedefs, written for C++ (works in C++ 11 only)
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
@davisford
davisford / setup-avahi.sh
Created July 12, 2013 14:14
Setup avahi-daemon on Ubuntu for so you can reach hostname `ubuntu.local` from host OS
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan
@jendiamond
jendiamond / gist:6128723
Last active April 11, 2024 11:35
Creating your own Gem & Command Line Interface Using Bundler

Presentation slides

Create a Gem - Make it a CLI - Add Rspec Tests

Create a Gem - Make it a Command Line Interface - Add Rspec Tests Using Bundler & Thor

#Creating your own Gem

  1. Run this command in your Terminal. This creates and names all the files you need for your gem. We are going to create a Lorem Ipsum Generator; you can call it whatever you want but seeing as we are creating a Lorem Ipsum generator we'll call it lorem. Read about gem naming conventions.
@rofl0r
rofl0r / init.c
Created August 6, 2013 21:15
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@dgrant
dgrant / ordered_dicts_python.py
Created August 25, 2013 06:20
An ordered dict implementation in Python using a second hash map to store the order information.
#!/usr/bin/env python
import random
import operator
import time
from collections import OrderedDict
import unittest
class ordered_dict(dict):
def __init__(self):
self.order = {}
@Menencia
Menencia / readme.md
Last active March 8, 2022 18:29
Script to update a git project

Update a git repo

With this script, you can easily update a git repo.

Install

curl -# https://gist.githubusercontent.com/Menencia/6435756/raw/update.sh > update.sh
curl -# https://gist.githubusercontent.com/Menencia/6435756/raw/version.sh > version.sh
@codingoutloud
codingoutloud / make-keys.bat
Last active October 3, 2024 07:10
Handy OpenSSL command-line combinations I've used - they might've been hard to find or come up with, so capturing them here.
@echo off
if _%1_==__ goto USAGE
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=My Cert Name"
openssl pkcs12 -export -out mycert.pfx -inkey mycert.pem -in mycert.pem -passout pass:%1
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
openssl pkcs12 -in mycert.pfx -nodes -passin pass:%1 | openssl x509 -noout -fingerprint
openssl x509 -in mycert.pem -noout -fingerprint