Skip to content

Instantly share code, notes, and snippets.

@interputed
interputed / mega-millions.py
Last active October 24, 2018 16:06
Mega-Millions Simulator in Python3
#!/bin/python3
import random
def GetTime(draws):
# Just a helper function for printing how much time has passed to win the jackpot.
years = draws // 104
rem = draws % 104
weeks = rem // 2
return "{} years and {} weeks".format(years, weeks)
diff --git a/src/globals.h b/src/globals.h
index 9cf8455..5b06f86 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -36,8 +36,7 @@ EXTERN long Columns INIT(= 80); /* nr of columns in the screen */
* "LineOffset[n]" is the offset from ScreenLines[] for the start of line 'n'.
* The same value is used for ScreenLinesUC[] and ScreenAttrs[].
*
- * Note: before the screen is initialized and when out of memory these can be
- * NULL.
@thehans
thehans / rounded_cube.scad
Last active November 3, 2019 20:50
Rounded cube implementation
use <functional.scad>
$fa = 0.1;
$fs = 0.1;
module rounded_cube(size, r=0, center=false) {
s = is_array(size) ? size : [size,size,size];
c = is_array(center) ?
[center.x ? 0 : s.x, center.y ? 0: s.y, center.z ? 0 : s.z]/2 :
(center ? 0 : s/2);
@xsot
xsot / instructions.md
Last active March 3, 2024 13:42
sed maze solver

Usage

sed -E -f solver.sed input where input is a file containing the maze.

For best results, resize your terminal to match the height of the maze. To disable animations, delete the lines containing p.

Maze format

The solver assumes the following:

  • The maze only contains the characters # \nSE
  • Every line has the same number of characters
  • There is only one start (S) and end (E)
af0133ff9d85fa2ef499fe7d09d5ca1167a37bfd04efb1bb58fb8b4dd91ab8ca
4a1476e504d73879ac82c762f21266954e315f9496577ada4b59645517c3a436
edc6cc18e5478e8faa35970f6ec03c9c249d90b38b92ede5a63bb9dad75055ce
64f4e992563fd187eb34d5ba72ae6fd5088670ca2e1b32a6a03454c17d03088e
df54fcffc3f9b42efc5ad027d0009c22e0feb964fbb927b48ac9ee27b409b80c
0eb6d6ed92b57d7c41e94a8e9efd5210de891e10ecec839debe4238237b84315
2037f49617112f92196a0b11c0e3850f1423ef5518c9186316eacc6d9fd00354
de1b9e3b1ab7828d8cf1a02080ac850112c2e8aacf0025ca7d445ecbc029b890
7906a5a0aba725ed0a2918ca1c3acbc841d313416f0b359b24fff06724dee1e9
eab8d6080b0a2765eb43f357d08933b543f62f896dcea4b76f4da9d928c0cf89
@corylulu
corylulu / DisableNewProfiles.user.js
Last active November 12, 2017 15:29
Disable new Profiles for Reddit
// ==UserScript==
// @name Disable New Profiles
// @namespace http://tampermonkey.net/
// @version 1.1.1
// @description Modifies all profile links to bring you to the overview page by default. Also adds an "Overview" tab to the new Profile page and a "Profile" tab to the overview page.
// @author /u/corylulu
// @match https://www.reddit.com/*
// @grant none
// @require https://raw.githubusercontent.com/uzairfarooq/arrive/master/minified/arrive.min.js
// ==/UserScript==
@rverton
rverton / cowroot.c
Created October 21, 2016 14:06
CVE-2016-5195 (DirtyCow) Local Root PoC
/*
* (un)comment correct payload first (x86 or x64)!
*
* $ gcc cowroot.c -o cowroot -pthread
* $ ./cowroot
* DirtyCow root privilege escalation
* Backing up /usr/bin/passwd.. to /tmp/bak
* Size of binary: 57048
* Racing, this may take a while..
* /usr/bin/passwd overwritten
@lestoni
lestoni / gist:8c74da455cce3d36eb68
Last active May 23, 2024 23:18
vim folding cheatsheet

via (https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
@hurjas
hurjas / timestamp.js
Created May 11, 2012 15:35 — forked from jonkemp/timestamp.js
Print out a nicely formatted timestamp in JavaScript.
/**
* Return a timestamp with the format "m/d/yy h:MM:ss TT"
* @type {Date}
*/
function timeStamp() {
// Create a date object with the current time
var now = new Date();
// Create an array with the current month, day and time