Instantly share code, notes, and snippets.

View omregner.js
function wattToKwatt(watts){
kilowatts = watts/1000;
return kilowatts
}
exports.calcsWatt = wattToKwatt;
View pattern2.js
function pattern2 (num) {
// Set count = 0
let count = 0;
// Print the pattern
for (let i=1; i<=num; i++) {
let currentLine = '';
for (let j=1; j<=i; j++) {
count++;
currentLine += count + ' ';
View gist:61c2bb37be7bb2f63dc758bf64e9e024
public Integer[] myFlatten(Object[] input) throws IllegalArgumentException {
if (input == null) return null;
List<Integer> result = new ArrayList<Integer>();
for (Object e : input) {
if (e instanceof Integer) {
result.add((Integer) e);
} else if (e instanceof Object[]) {
View Pattern2.java
import java.util.Scanner;
public class Pattern2 {
public static void main (String[] args) {
System.out.println("/* ===== Pattern #2 ===== */");
Scanner input = new Scanner(System.in);
int n = input.nextInt(), i, j, count=0;
// Print the pattern
for (i=1; i<= n; i++) {
View exceptions.py
from rest_framework.views import exception_handler
from rest_framework.exceptions import ErrorDetail, _get_full_details
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the standard error response.
response = exception_handler(exc, context)
# Now add the HTTP status code to the response.
View .tmux.conf
#https://gist.github.com/spicycode/1229612
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
set -g status-keys vi
setw -g mode-keys vi
View difference.js
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
View Generate PHPDTOS.groovy
import com.intellij.database.model.DasTable
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
/*
* Available context bindings:
* SELECTION Iterable<DasObject>
* PROJECT project
* FILES files helper
*/
View .gitlab-ci.yml
image: node:6.11.3
cache:
key: cache_yarn
paths:
- .cache_yarn
stages:
- install
- build
View .block
license: mit