Skip to content

Instantly share code, notes, and snippets.

@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@piboistudios
piboistudios / parent-children-tree.rs
Last active December 31, 2023 14:15 — forked from rust-play/playground.rs
[RUST]Parent-Children Tree (#2)
// we will use weak references with the Rc<T> (reference counting pointer) type
// weak references allow us to make references to a value that will -not- keep it alive
// this is perfect in the intsance of children, as we will soon see
use std::rc::{Rc,Weak};
use std::cell::RefCell;
// this example builds upon the last by storing a vector of children as well as a parent
#[derive(Debug)]
struct Node {
@peterc
peterc / websocket_backend.rb
Created May 13, 2017 17:09
A WebSocket backend for a Rack-based (using Puma) Ruby app that distributes messages received via Redis
# This file's job is to accept WebSocket connections
# and pass along Redis messages to them
require 'faye/websocket'
class WebSocketBackend
def initialize(app)
@app = app
@clients = []
@running = false
@thisiscetin
thisiscetin / heaps.go
Last active January 18, 2024 08:52
Heap's algorithm with Go Lang for possibile permutations of N objects.
// Suppose we have a permutation containing N different elements.
// Heap found a systematic method for choosing at each step a pair of elements to switch,
// in order to produce every possible permutation of these elements exactly once.
// Let us describe Heap's method in a recursive way. First we set a counter i to 0.
// Now we perform the following steps repeatedly until i is equal to N.
// We use the algorithm to generate the (N − 1)! permutations of the first N − 1 elements,
// adjoining the last element to each of these. This generates all of the permutations that
// end with the last element. Then if N is odd, we switch the first element and the last one,
// while if N is even we can switch the i th element and the last one (there is no difference between
// N even and odd in the first iteration). We add one to the counter i and repeat. In each iteration,
@htp
htp / curl-websocket.sh
Last active May 14, 2024 21:24
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@donghee
donghee / gist:62dbeb76ca0ac21c3053
Created January 27, 2016 09:51
XFCE / Xubuntu themes in Debian

Follow these steps to install Greybird theme and elementary XFCE icons. This is the default theme in Xubuntu, but not in Debian and other derivatives. The following steps will give you that Xubuntu look in just 2 minutes!

# Install theme
mkdir -p ~/.themes
cd $_
wget https://github.com/shimmerproject/Greybird/archive/master.zip
unzip master.zip
rm master.zip
@kgriffs
kgriffs / vlc
Last active February 23, 2024 17:57
Run VLC from the command line on Mac OS X and stream internet radio (such as Radio Paradise).
#!/usr/bin/env bash
/Applications/VLC.app/Contents/MacOS/VLC -I rc "$@"