Skip to content

Instantly share code, notes, and snippets.

View sillyfellow's full-sized avatar
:octocat:
Why be normal?

Sandeep Sadanandan sillyfellow

:octocat:
Why be normal?
View GitHub Profile
@sillyfellow
sillyfellow / wordle-solver.py
Last active March 29, 2022 13:29
a hint, a bit of help..
import operator
import re
import sys
import urllib.request
banner_read_sofar = """Type what you know so far.
Keep the Green ones where they are, and leave '.' for unknown: """
banner_grey_letters = """Type in the grey letters
All, or the new ones you learned in previous step: """
import operator
import re
import sys
import urllib.request
banner_read_sofar = """Type what you know so far.
Keep the Green ones where they are, and leave '.' for unknown: """
banner_grey_letters = """Type in the grey letters
All, or the new ones you learned in previous step: """
import operator
import re
import sys
import urllib.request
banner_read_sofar = """Type what you know so far.
Keep the Green ones where they are, and leave '.' for unknown: """
banner_grey_letters = """Type in the grey letters
All, or the new ones you learned in previous step: """
@sillyfellow
sillyfellow / mutliflag.go
Last active June 2, 2020 07:44
An example for providing multiple values to the same command line parameter - with builtin `flag` in Go
// Package main shows an example for providing multiple values to the same
// command line parameter - with builtin `flag` in Go.
package main
import (
"flag"
"fmt"
"strings"
)
@sillyfellow
sillyfellow / sortedInsert.go
Last active May 22, 2020 13:12
Sometimes it is not enough to know whether an element is in the slice. One may want to insert a new element into the slice. But without knowing what is in the slice already. So, a slightly tweaked search will find the position where it should go.
package main
import (
"fmt"
"sort"
)
/*
Sometimes it is not enough to know whether an element is in the slice. One
may want to insert a new element into the slice. But without knowing what
function flatten(arr) {
if (arr.length == 0) {
return [];
}
const first = arr[0];
const flatRest = flatten(arr.slice(1));
if (!Array.isArray(first)) {
return [first].concat(flatRest);
dm-crypt with LUKS
------------------
LUKS with dm-crypt has better encryption and makes it possible to have multiple passphrase for the same partition or to change the password easily. To test if LUKS is available, simply type # cryptsetup --help, if nothing about LUKS shows up, use the instructions below Without LUKS. First create a partition if necessary: fdisk /dev/sdc.
Create encrypted partition
# dd if=/dev/urandom of=/dev/sda3 # Optional. For paranoids only (takes days)
# cryptsetup -y luksFormat /dev/sda3 # This destroys any data on sda3
# cryptsetup luksOpen /dev/sda3 sda3
# mkfs.ext3 /dev/mapper/sda3 # create ext3 file system
/*
* Binary Tree
* Binary Search Tree
* AVL Tree
*
* All in pure Javascript, ES6 classes and with inheritance.
*/
package main
import "fmt"
// VanEck generates the first n elements in the Van-Eck sequence
// https://oeis.org/A181391
// Thanks to: https://www.youtube.com/watch?v=etMJxB-igrc
func VanEck(limit int64) []int64 {
// prepare the basics. The output, and the lookup
package main
import (
"fmt"
)
// fillChannel simply fills the channel with i, i+2, i+4, ...
func fillChannel(ch chan int, i int) {
for {
ch <- i