Skip to content

Instantly share code, notes, and snippets.

@nolstedt
nolstedt / preRequestScript.js
Last active May 6, 2022 13:53 — forked from ptrstpp950/preRequestScript.js
Calculate TOTP in Postman
//Article about TOTP on my blog https://stapp.space/generate-totp-in-postman/
/**
* @preserve A JavaScript implementation of the SHA family of hashes, as
* defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
* HMAC implementation as defined in FIPS PUB 198a
*
* Copyright Brian Turek 2008-2017
* Distributed under the BSD License
* See http://caligatio.github.com/jsSHA/ for more information
@nolstedt
nolstedt / git.migrate
Created April 27, 2022 06:53 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
//Returns ISO 8601 week number and year
Date.prototype.getFullWeek = function(){
var jan1, w, d = new Date(this);
d.setDate(d.getDate()+4-(d.getDay()||7)); // Set to nearest Thursday: current date + 4 - current day number, make Sunday's day number 7
jan1 = new Date(d.getFullYear(),0,1); // Get first day of year
w = Math.ceil((((d-jan1)/86400000)+1)/7); // Calculate full weeks to nearest Thursday
return {y: d.getFullYear(), w: w };
};
//Returns ISO 8601 week number
Date.prototype.getWeek = function(){
# Instlled Xcode, Github and Sublime Text 3 by runing their installation packages.
git config --global user.name "Your Full Name"
git config --global user.email "Your Email Address"
# Homebrew Installation:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew doctor
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@nolstedt
nolstedt / gist:9dd7835b874e6d6bc64d
Created June 26, 2014 08:37
rsync copy/move with progress, cp mv progress
alias rsynccopy='rsync --partial --progress --append --rsh=ssh -r -h '
alias rsyncmove='rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files'
@nolstedt
nolstedt / rownum test
Last active December 14, 2015 14:19
Oracle rownum vs Postgres
create table rownum_tst (
id integer,
vc varchar(20)
);
insert into rownum_tst(id,vc) values(1,'4');
insert into rownum_tst(id,vc) values(2,'4,5');
select * from
(select rownum as position, vc from rownum_tst)
@nolstedt
nolstedt / gist:4618960
Created January 24, 2013 09:09
Visa log från postgres
#!/bin/bash
tail -f /opt/PostgresPlus/9.1AS/data/pg_log/`ls -t /opt/PostgresPlus/9.1AS/data/ pg_log/ | head -1`
@nolstedt
nolstedt / gist:4603933
Created January 23, 2013 10:07
git alias
alias lg='git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
alias gl="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"