Skip to content

Instantly share code, notes, and snippets.

@ParasoftExamples
ParasoftExamples / parameterized_test_example_8.java
Created September 7, 2018 21:12
Junit Parameterized Tests Example 8
public class LoanProcessorParameterizedTest {
@ParameterizedTest(name="Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}")
@MethodSource("testRequestLoan_Parameters")
public void testRequestLoan(float loanAmount, float downPayment, float availableFunds,
boolean expectApproved, String expectedMessage) throws Throwable
{
...
}
@alexsasharegan
alexsasharegan / wrapErr.ts
Created January 25, 2018 17:26
Go-like error handling with Typescript.
export async function wrapErr<T>(p: Promise<T>): Promise<[any, T | undefined]> {
try {
return [undefined, await p];
} catch (err) {
return [err, undefined];
}
}
let [err, value] = await wrapErr(somePromiseFunc());
if (err) {
@muktupavels
muktupavels / toggle-decorations.c
Last active July 14, 2024 02:21
Simple app to toggle window decorations.
/*
* Copyright (C) 2017 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@mattdrose
mattdrose / gist:2dd3f0487d494672d82f
Last active September 26, 2016 16:50 — forked from djs070/gist:4570480
Install NVM & Node 4.4.0 on Fedora/CentOS
# get nvm
git clone git://github.com/creationix/nvm.git ~/nvm
# activate nvm
echo "source ~/nvm/nvm.sh" >> ~/.bashrc
source ~/.bashrc
@f1sherman
f1sherman / forwarding-example.md
Last active March 12, 2021 00:21
Port Forwarding Example in OS X El Capitan

Add the following to /etc/pf.anchors/myname:

rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001

Add the following to /etc/pf-myname.conf:

rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/myname"
@asugai
asugai / Install composer on Amazon AMI running on EC2
Last active May 14, 2024 15:14
Install composer on Amazon AMI running on EC2
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
@ngryman
ngryman / README.md
Last active January 16, 2023 14:07
intellij javascript live templates

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.
@juanpabloaj
juanpabloaj / moda_media.py
Created May 30, 2012 02:13
ejemplo python: moda y mediana
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://docs.python.org/tutorial/datastructures.html
l = [ 1, 10, 4, 2, 4, 3, 3, 1, 1, 3]
print l
promedio = sum(l)/len(l)
@jogi
jogi / mergesort.py
Created May 17, 2012 18:16
Recursive Mergesort in Python
def merge(left, right):
if not len(left) or not len(right):
return left or right
result = []
i, j = 0, 0
while (len(result) < len(left) + len(right)):
if left[i] < right[j]:
result.append(left[i])
i+= 1
@bergantine
bergantine / gist:2623697
Last active November 20, 2019 13:38
Create md5 Hash of a File using Python. #python #md5 #hash
import hashlib
filehash = hashlib.md5()
filehash.update(open('/path/to/file.zip').read())
print filehash.hexdigest()