Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.
- Go to
settings. - Search for
live templates. - Under the javascript section you should be able to manage your templates.
| import hashlib | |
| filehash = hashlib.md5() | |
| filehash.update(open('/path/to/file.zip').read()) | |
| print filehash.hexdigest() |
| 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 |
| #!/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) |
| $ 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 |
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 4001Add the following to /etc/pf-myname.conf:
rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/myname"| # get nvm | |
| git clone git://github.com/creationix/nvm.git ~/nvm | |
| # activate nvm | |
| echo "source ~/nvm/nvm.sh" >> ~/.bashrc | |
| source ~/.bashrc |
| /* | |
| * 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 |
| 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) { |
| 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 | |
| { | |
| ... | |
| } |