Skip to content

Instantly share code, notes, and snippets.

// Answering the "how many squares" problem (my answer = 40):
//
// http://media-geeks.com/special-features/how-many-squares-indeed/
//
// HasCanvas:
//
// http://hascanvas.com/Counting-Squares
//
// GIF outptu:
//
@huonw
huonw / main.rs
Created October 13, 2015 06:25 — forked from RustyRails/main.rs
Challenge #236 [Easy] Random Bag System
extern crate rand;
use rand::Rng;
struct Bag {
contents: Vec<char>,
rng: rand::ThreadRng,
}
impl Bag {
@mbbx6spp
mbbx6spp / 00README.adoc
Last active February 8, 2021 01:39
My ${HOME}/.nixpkgs/config.nix to setup my dev and desktop environments the way I like them :)

User env setup

Setup your user environment just the way you want with Nix.

  1. Add packageOverrides to the attrset returned by your ${HOME}/.nixpkgs/config.nix (see my example above).

  2. Then with one command you can setup your whole environment: nix-env -i desktop-mbbx6spp.

Then all you need is a simple ~/.bash_profile script like so:

@kuznero
kuznero / install-from-channels-nix.md
Last active April 25, 2021 19:05
How to build haskell project in NixOS with stack

In order to upgrade Haskell stack tool on NixOS without enabling nixos-unstable for all packages it is possible to install just one single package from unstable channel like following:

nix-env -f https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz -iA stack

If it happens that it is still older version, try unstable-small channel instead which gets updated more often:

nix-env -f https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable-small.tar.gz -iA stack
@karanlyons
karanlyons / ZoomDaemon.yara
Last active July 12, 2021 14:07
Fixes for Zoom, RingCentral, Zhumu (and additional white labels) RCE vulnerabilities
private rule Macho
{
meta:
description = "private rule to match Mach-O binaries (copied from Apple's XProtect)"
condition:
uint32(0) == 0xfeedface or uint32(0) == 0xcefaedfe or uint32(0) == 0xfeedfacf or uint32(0) == 0xcffaedfe or uint32(0) == 0xcafebabe or uint32(0) == 0xbebafeca
}
rule ZoomDaemon
{
{ config, pkgs, ... }:
{
require = [
<nixos/modules/programs/virtualbox.nix>
./hardware.nix
./monitors.nix
# ./mailpile.nix
];
@urjeetpatel
urjeetpatel / gist:60cee1e7dc509ead24e99f70de3b5bd7
Last active April 19, 2022 18:27 — forked from bergantine/gist:1119284
Python Random Password Generator (One Liner). #python #password
python -c "LENGTH=15;from secrets import choice;from string import printable; print(''.join([choice(printable.strip()) for i in range(LENGTH)]))"
@samnang
samnang / gist:1759336
Created February 7, 2012 11:52
Install Bash version 4 on MacOS X
# Install Bash 4 using homebrew
brew install bash
# Or build it from source...
curl -O http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
tar xzf bash-4.2.tar.gz
cd bash-4.2
./configure --prefix=/usr/local/bin && make && sudo make install
# Add the new shell to the list of legit shells
@ccbrown
ccbrown / DumpHex.c
Last active March 27, 2024 17:32
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh