Skip to content

Instantly share code, notes, and snippets.

@bozheville
bozheville / name-generator.js
Created June 22, 2018 10:10
random name generator
const randomContactName = () => {
const getCharFrom = set => set.charAt(
Math.round( Math.random() * ( set.length - 1 ) )
);
const getVowel = () => getCharFrom( 'aeiouy' );
const getConsonant = () => getCharFrom( 'bcdfghjklmnpqrstvwxz' );
let name = getConsonant() + getVowel() + getConsonant();
if ( Math.random() >= 0.5 ) {
require 'socket'
require 'rack'
require 'rack/lobster'
app = Rack::Lobster.new
server = TCPServer.new 5678
while session = server.accept
request = session.gets
puts request
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 30, 2024 18:17
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@jelbourn
jelbourn / api-provider.js
Last active February 25, 2024 12:51
Example of using an angular provider to build an api service. Subject of August 20th 2013 talk at the NYC AngularJS Meetup. http://www.meetup.com/AngularJS-NYC/events/134578452/See in jsbin: http://jsbin.com/iWUlANe/5/editSlides: https://docs.google.com/presentation/d/1RMbddKB7warqbPOlluC7kP0y16kbWqGzcAAP6TYchdw
/**
* Example of using an angular provider to build an api service.
* @author Jeremy Elbourn (@jelbourn)
*/
/** Namespace for the application. */
var app = {};
/******************************************************************************/
@futuremill-ltd
futuremill-ltd / gist:2318876
Created April 6, 2012 11:00
Building Ruby 1.9.3 package for Debian Squeeze
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
@TeWu
TeWu / gist:1234573
Last active February 2, 2022 20:23
TCP client and multithreaded server in 14 lines of Ruby code

TCP client and multithreaded server in 14 lines of Ruby code

Server:

require "socket"
server = TCPServer.open(2626)
loop do
	Thread.fork(server.accept) do |client| 
 client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
@kentbrew
kentbrew / setMultiHeaders.js
Created January 10, 2011 22:57
Setting multiple cookies (or whatever) per header with Node. Bonus: p3p line prevents IE from spazzing out.
response.writeHead(200, {
'p3p': ['policyref="http://foo.com/p3p.xml"', 'CP="OOO EEE OOH AH AHH"'],
'Set-Cookie': ['ting="tang; expires=0; path=/;"', 'wallawalla="bingbang; expires=123456789; path=/;"'],
'Content-Type': 'text/html'
});