Skip to content

Instantly share code, notes, and snippets.

require "big_int"
struct BigInt2 < Int
def initialize(num : Int::Signed)
if LibC::Long::MIN <= num <= LibC::Long::MAX
LibGMP.init_set_si(out @mpz, num)
else
LibGMP.init_set_str(out @mpz, num.to_s, 10)
end
end
@mxriverlynn
mxriverlynn / webcam.css
Last active March 30, 2020 12:05
webrtc webcam in 20 lines
body {
margin: 0px;
padding: 0px;
}
#player {
width: 100%;
height: 100%;
}
@patriques82
patriques82 / Ruby tricks
Last active July 12, 2017 09:59
A list of Ruby tricks from the book "the ruby programming language"
Equality
The equal? method is defined by Object to test whether two values refer to exactly the same
object. For any two distinct objects, this method always returns false:
a = "Ruby" # One reference to one String object
b = c = "Ruby" # Two references to another String object
a.equal?(b) # false: a and b are different objects
b.equal?(c) # true: b and c refer to the same object
By convention, subclasses never override the equal? method. The == operator is the most common
@benjamingeiger
benjamingeiger / gist:3627064
Created September 4, 2012 21:52
Cartesian product of lists in Python.
def cartesian (lists):
if lists == []: return [()]
return [x + (y,) for x in cartesian(lists[:-1]) for y in lists[-1]]
print cartesian([[1, 2, 3], [2, 4, 6], [3, 6, 9]])
@campadrenalin
campadrenalin / main.md
Created January 25, 2012 18:56
Getting started with Meshnet

Getting started with Meshnet

This document is for people who want to help but have no technical knowledge. It assumes you won't be getting involved in squabbles over which relay technology to use, etc.

Step 1: Set up CJDNS

One of the few things widely agreed upon at the time of this writing is the use of CJDNS. Currently Windows is not supported, but if you have Linux or can run Linux in a virtual machine, you can follow the step-by-step instructions lower on that page to install and start up an instance of CJDNS on your system. If you're using Ubuntu 11.10 (latest version), you can follow these simplified instructions.

One thing you should know is cjdns currently isn't a wireless meshnet. A physical meshnet consisting of nodes geographically close to each other is a long way off. Instead, cjdns offers a "mixnet"-like system. cjdns is routable over the current Internet, so this means right now its like a giant VPN (virtu

@usure
usure / irx.sh
Created October 28, 2011 00:42
SystemMonitor BASH
#!/bin/bash
############# SYSTEM MONITOR ######################
#Made by Gregory12z
#UNFINISHED. Only shows minimal info. ALSO... Next version will use ncurses.
#Enjoy.
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
@azproduction
azproduction / gist:1292557
Created October 17, 2011 13:03
Simple Google Dart HTTP Server
/**
* Simple HTTP server on Dart
* @see http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/runtime/bin/socket_impl.dart
* http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/runtime/bin/socket_stream.dart
*
* Based on http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/samples/socket/SocketExample.dart
* @author azproduction
*/
class HttpExample {
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@joshuapowell
joshuapowell / HTML5 Stub
Created April 12, 2011 04:53
A generic & empty HTML5 page structure.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="robots" content="index, follow" />
@somic
somic / udp_hole_punch_tester.py
Created November 3, 2009 04:13
UDP Hole Punching test tool
#!/usr/bin/env python
#
# udp_hole_punch_tester.py - UDP Hole Punching test tool
#
# Usage: udp_hole_punch_tester.py remote_host remote_port
#
# Run this script simultaneously on 2 hosts to test if they can punch
# a UDP hole to each other.
#
# * remote_port should be identical on 2 hosts.