Skip to content

Instantly share code, notes, and snippets.

@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active July 25, 2024 03:38
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@joaoneto
joaoneto / login.test.js
Created March 13, 2013 13:49
Login session test with mocha
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')
@douglasmiranda
douglasmiranda / gist:5408278
Created April 17, 2013 22:26
Leading zeros in django templates
{{ variable|stringformat:"02d" }}
@mlouro
mlouro / gulpfile.js
Last active June 21, 2022 23:20
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
@ramanqul
ramanqul / cyrillic2latin_file_renamer.py
Created March 14, 2015 20:42
Cyrillic to Latin File Changer
#!/usr/bin/python
# -*- coding: utf-8 -*-
from os import walk, rename, unlink, mkdir, remove
from os.path import isdir, exists
from sys import argv, exit, getfilesystemencoding
from shutil import copyfile
import shutil
conversion = {
@Wtower
Wtower / config.fish
Last active October 20, 2022 21:47
Using fish shell with python virtualenv, node nvm and ansible
# Greeting prologue
echo "Welcome to "(uname -a | awk '{print $1 " " $2 " " $3 " " $4 " " $12}')
uptime
# ansible
. ~/workspace/ansible/ansible/hacking/env-setup.fish -q > /dev/null ^&1
set -Ux ANSIBLE_INVENTORY ~/workspace/ansible/play/hosts
echo "Now using "(ansible --version | head -n 1 | awk '{print $1 " " $2}')
# Load virtual fish
@Wtower
Wtower / README.rst
Last active December 8, 2020 06:16
Bi-directional many-to-many relationship in django admin

Accessing a ManyToMany relationship from both ends

Based on the article `Related ManyToManyField in Django admin site`_, the file forms.py contains a summary of the recommended code.

The file manytomany.py contains a generic base class in order to be DRY and avoid repeating the same code in many form classes.

An example of how to use can be found in the NineCMS_ project commit 52c710f_.

@lgyanf
lgyanf / add_query_parameters.py
Created June 14, 2016 10:49
A python decorator that adds query parameters to django-rest-framework swagger docstring.
# -*- coding: utf-8 -*-
import collections
import yaml
from rest_framework import fields
"""
Convert rest_framework.fields classes to Swagger data types according to http://swagger.io/specification/
Return 'string' by default.
@Wtower
Wtower / install.sh
Created September 14, 2016 10:51
Toradex install prerequisites and flash
#!/bin/bash
# install programs:
sudo apt-get install gksu gtkterm
# run terminal:
gksu gtkterm
# extract image iso:
bzip2 -d Colibri_VF_LinuxImageV2.6Beta2_20160630.tar.bz2
@macbookandrew
macbookandrew / findStyles.js
Last active March 30, 2024 15:24
List unique CSS properties for all DOM elements
/**
* List unique CSS properties for all DOM elements
* Initially created to list unique font stacks on a page
* @see {@link http://stackoverflow.com/a/35022690/ Inspired by this StackOverflow answer}
*
* @see {@link https://gist.github.com/macbookandrew/f33dbbc0aa582d0515919dc5fb95c00a/ URL for this file}
*
* @author AndrewRMinion Design (https://andrewrminion.com)
* @version 1.1
*