Skip to content

Instantly share code, notes, and snippets.

View DeviaVir's full-sized avatar
🏴‍☠️

Chase DeviaVir

🏴‍☠️
View GitHub Profile
def main():
values = map(int, raw_input().split(','))
return reduce(lambda x, y: x ^ y, values)
print main()
# Because ^ (XOR) returns 0 for each pair and there is only one unpaired item in the input.
# E.g.
# 1 ^ 1 = 0
def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
def main(i=0):
if i is 0:
return 0
class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
class LinkedList:
def __init__(self):
self.root = None
def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
def main():
i = int(raw_input())
if i is 0:
@stefanfoulis
stefanfoulis / docker_for_mac_disk_default_size.md
Last active June 29, 2023 12:02
How to resize Docker for Mac Disk image and set the default size for new images

Set the default size for new Docker for Mac disk images

UPDATE: The instructions here are no longer necessary! Resizing the disk image is now possible right from the UI since Docker for Mac Version 17.12.0-ce-mac49 (21995).

If you are getting the error: No space left on device

Configuring the qcow2 size cap is possible in the current versions:

# my disk is currently 64GiB
resource "aws_iam_user" "asg_healthreport" {
name = "${var.stack}-asg_healthreport"
# can't use create_before_destroy due to fixed name
}
resource "aws_iam_access_key" "asg_healthreport" {
user = "${aws_iam_user.asg_healthreport.name}"
# can't use create_before_destroy due to fixed name of user
}
// Double all numbers
> Promise.map([1, 2, 3], function(num) { return num * 2; }).then(function(numbers) { console.log("The final list of numbers:", numbers); })
The final list of numbers: [ 2, 4, 6 ]
// Remove all the odd numbers
> Promise.filter([1, 2, 3], function(num) { return (num % 2) == 0; }).then(function(numbers) { console.log("The final list of numbers:", numbers); })
The final list of numbers: [ 2 ]
// Sum all the numbers
> Promise.reduce([1, 2, 3], function(total, num) { return total + num; }, 0).then(function(number) { console.log("The final value:", number); })
@joepie91
joepie91 / functional.js
Last active February 16, 2021 05:12
Functional programming (map, filter, reduce) in bluebird
/* Double all numbers */
Promise.map([1, 2, 3], function(num) {
return num * 2;
}).then(function(numbers) {
console.log("The final list of numbers:", numbers);
//The final list of numbers: [ 2, 4, 6 ]
});
/* Remove all the odd numbers */
Promise.filter([1, 2, 3], function(num) {
@DeviaVir
DeviaVir / email.eml
Created January 8, 2015 08:39
Formal complaint to Spamhaus
Dear Spamhaus,
We would like to submit a formal complaint regarding one of your divisions, the CBL (CBL.abuseat.org), and hope you will swiftly take action regarding these practices.
Two days ago, our customers started to notify us that we were blacklisted.
The CBL had picked this up using a sinkhole, and had banned our IP's. Upon investigation we found several hacked wordpress and joomla websites, that were being abused, we cleaned these up and forced the customers to upgrade.
This seemed to not please the CBL, however, as they already enforced a 48 hour ban on all of our IP's. One IP address which was not even active the last month. Imagine our surprise when we tried to switch one out to use it. I think it's outrageous to immediately enforce a 48 hour ban on any IP connecting to the sinkhole, these IP's are used to send legitimate e-mail (usually), and all of our customers are impacted by this practice.
We would like to suggest to you to use a different practice, please do not ban IP's for 48 (!) hours
@eezis
eezis / hist command search
Last active October 1, 2015 08:56
Incremental Search History for the OS X Terminal (type a partial command, up arrow / down arrow to search)