Skip to content

Instantly share code, notes, and snippets.

View kjellski's full-sized avatar
🤓
learning every day...

Kjellski kjellski

🤓
learning every day...
View GitHub Profile
@kjellski
kjellski / PowerShell Customization.md
Created September 2, 2020 12:40 — forked from jchandra74/PowerShell Customization.md
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@kjellski
kjellski / killport
Created June 19, 2020 07:43
kill a process running on a port
#!/bin/bash
lsof -n -i4TCP:$1 | awk '{print $2}' | tail -1 | xargs kill
@kjellski
kjellski / Container.js
Last active April 27, 2020 12:06
Workarround for `pollInterval` with `@apollo/react-hooks/useQuery`
// NOTE: not using poll here because the interval needs to change on every call.
// So we're using multiple hooks to achieve this:
// 1. `useInterval` to keep the recalculation with `setVariablesIntervalCallback` triggering
// 2. `useState` to have a clear state change when we called `setVariablesIntervalCallback`
// 3. `usePrevious` to have data while new data is beeing fetched so the table can stay intact
const Container = ({ children, someValue }) => {
const [variables, setVariables] = useState({
someValue,
value: calculateValue(),
})
@kjellski
kjellski / authorize.js
Created May 24, 2018 06:49 — forked from kndt84/authorize.js
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;

Keybase proof

I hereby claim:

  • I am kjellski on github.
  • I am kjellski (https://keybase.io/kjellski) on keybase.
  • I have a public key ASCJATSC-3yUirUgjDcACMHAhoP_M-djsx60suVhTCKpNQo

To claim this, I am signing this object:

@kjellski
kjellski / akka-config.hocon
Created June 10, 2015 09:06
Hocon config for logging
akka {
loglevel = DEBUG
stdout-loglevel = DEBUG
loggers = [ "Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog" ]
actor {
debug {
# enable function of LoggingReceive, which is to log any received message at
# DEBUG level
unhandled = on
@kjellski
kjellski / _service.md
Last active August 29, 2015 14:20 — forked from naholyr/_service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@kjellski
kjellski / etc_init.d_teamcity
Created April 24, 2015 21:35
TeamCity Installation
#!/bin/sh
# /etc/init.d/teamcity - startup script for teamcity
export TEAMCITY_DATA_PATH="/usr/local/.BuildServer"
case $1 in
start)
echo "Starting Team City"
start-stop-daemon --start -c teamcity --exec /usr/local/TeamCity/bin/teamcity-server.sh start
;;
stop)
//let rec at (pos: int) (l: 'a list) : 'a Option =
// if pos - 1 > l.Length - 1 then
// None
// else if pos = 1 then
// Some(l.Head)
// else
// at (pos - 1) l.Tail
let rec at pos = function
| [] -> None