Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Phillip Brink binki

View GitHub Profile
@CollinChaffin
CollinChaffin / How_to_disable_ATT_DNS_Redirection.md
Created Aug 29, 2018
How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44
View How_to_disable_ATT_DNS_Redirection.md

How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44

Issue

DNS queries on home network suddenly resolving hosts to 104.239.207.44.

Symptoms

You will see SPORADIC mis-resolutions of EVERYTHING to that 104.239.207.44 address if their crappy router happens to hear your PC's DHCP request - EVEN IF ANOTHER DHCP SERVER ON THE NETWORK assigns the ultimate address.

@binki
binki / code.csx
Created Jul 6, 2018
Type.IsAssignableFrom Truth Table
View code.csx
Console.WriteLine("| `left` | `right` | `left.IsAssignableFrom(right)` |");
Console.WriteLine("| --- | --- | --- |");
var types = new[] {
typeof(object),
typeof(string),
};
foreach (var left in types) {
foreach (var right in types) {
Console.WriteLine($"| {left} | {right} | {left.IsAssignableFrom(right)} |");
}
@ljw1004
ljw1004 / tuple_perf.cs
Created Apr 20, 2017
Perf comparison ValueTuple vs Tuple vs KeyValuePair
View tuple_perf.cs
// TUPLE MICRO-BENCHMARKS, based on https://www.dotnetperls.com/tuple-keyvaluepair
//
// Tuples are generally fastest.
// ValueTuple is fastest in the particular case of GetHashCode.
// KeyValuePair is always worst.
//
//
// RAW RESULTS
// Numbers in milliseconds (lower is better)
//
@binki
binki / Program.cs
Last active Jan 18, 2017
Play with C# string interpolation
View Program.cs
using System;
namespace FormattablePlay
{
class Program
{
static void Main(string[] args)
{
var stringVar = "plant";
Append($"SELECT * FROM blah b WHERE b.Thing = {stringVar}");
@danverbraganza
danverbraganza / hangman.py
Last active Apr 20, 2017
Hangman implemented in 3 lines of Python! For an explanation of how this works, see http://danverbraganza.com/writings/hangman-in-3-lines-of-python
View hangman.py
license, chosen_word, guesses, scaffold, man, guesses_left = 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10
while not all(letter in guesses for letter in chosen_word) and guesses_left: _, guesses_left = map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), max((10 - len(guesses - set(chosen_word))), 0)
print 'You', ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)], '\nWord was', chosen_word
@elsassph
elsassph / 1-loop-es6.js
Last active Dec 5, 2016
ES2015 / babel vs Haxe code generation
View 1-loop-es6.js
const a = [1,2,3];
var acc = 0;
for (const v of a) {
acc += v;
}
// want clean code? use Array.reduce
console.log(acc);
@luislavena
luislavena / howto-manually-add-trust-cert-to-rubygems.md
Last active Jan 18, 2021
Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)
View howto-manually-add-trust-cert-to-rubygems.md

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2016-12-01: Please refer to the official guide instead of this process.

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

@ungoldman
ungoldman / curl_post_json.md
Last active Feb 26, 2021
post a JSON file with curl
View curl_post_json.md

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@jammycakes
jammycakes / LazyDisposable.cs
Last active Jun 19, 2019
A subclass of System.Lazy<T> that implements IDisposable and forwards calls to the Dispose method on to the lazily created instance if it exists.
View LazyDisposable.cs
/// <summary>
/// A <see cref="Lazy"/> object that implements <see cref="IDisposable"/>.
/// </summary>
/// <typeparam name="T">
/// The object being lazily created.
/// </typeparam>
public class LazyDisposable<T> : Lazy<T>, IDisposable where T: IDisposable
{
/// <summary>