Skip to content

Instantly share code, notes, and snippets.

@kjakka
kjakka / jboss.plugin.zsh
Created June 5, 2021 00:19 — forked from chrisweibel/jboss.plugin.zsh
jboss deployment script
# Simple JBoss7 helper functions
# set var to jboss home dir
JBOSS_HOME="/usr/local/jboss/jboss-as-web-7.0.2.Final"
#Start BBoss
alias jboss-start="sudo $JBOSS_HOME/bin/standalone.sh"
#Stop JBoss
alias jboss-stop="sudo $JBOSS_HOME/bin/jboss-admin.sh --connect command=:shutdown"
@kjakka
kjakka / lru.go
Created May 27, 2021 04:23
LRUCache
package main
import (
"fmt"
)
type LRUCache struct {
Capacity int
Head *Node
Tail *Node
@kjakka
kjakka / akkad-bakkad.md
Last active April 15, 2020 14:55
akkad-bakkad

Puzzle Question

100 people standing in a circle in an order 1 to 100. No. 1 has a sword. He kills the next person (i.e. No. 2) and gives the sword to the next (i.e. No. 3). All people do the same until only 1 survives. Which number survives at the last? 🤔 Remember, they are in a circle. This will take some time, so don't worry about fastest finger first!

Method 1: Using a List

  • Manage state of Alive vs Dead in Node
  • Simulate circular linked list using list
  • Iterations using for loops and the Sword moves
  • []rune because string mutation is not allowed

https://play.golang.org/p/tgyCQu7YubV

@kjakka
kjakka / crosscompile.sh
Created November 1, 2019 02:59
cross compile on mac to get linux exe
# env sets is only used for this command ;)
env GOOS=linux GOARCH=amd64 go build ./...
@kjakka
kjakka / randpasswd.php
Last active April 15, 2020 15:51
Generate Random Password
<?php
// https://tehplayground.com/hkQaCIBCZVTnqq28
// https://repl.it/repls/RoundedHighOop
function generatePassword() {
return md5(rand());
}
function generatePasswordv2($len, $caps, $nums, $schr) {
$dict = array('alph'=>'abcdefghijklmnopqrstuvwxyz',
@kjakka
kjakka / looper.sh
Created October 28, 2019 22:45
loop over file
# walcats.txt has catIds one per line
while ((i++)); read -r line; do
echo "[$i/1148] Downloading category items for catId $line"
curl -H 'Accept-Encoding: gzip' "https://api.walmartlabs.com/v1/feeds/items?apiKey=<apikey>&format=json&categoryId=$line" >> parts.2824
done < walcats.txt
@kjakka
kjakka / tampermonkey.js
Last active October 21, 2019 18:39
user scripts to may my browsing easy on eyes
// ==UserScript==
// @name Gmail Ad Cleanup
// @namespace http://github.com/kjakka
// @version 0.1
// @description ads stuff
// @match *://*.google.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function addGlobalStyle(css) {
@kjakka
kjakka / vbox.md
Created October 7, 2019 15:08
Making Shared Folders work in Ubuntu vbox
$ sudo mount /dev/cdrom /mnt/cdrom
$ sudo apt-get install make gcc linux-headers-$(uname -r)
$ sudo /mnt/cdrom/VBoxLinuxAdditions.run
@kjakka
kjakka / .bashrc
Created September 23, 2019 16:09
isql alias
echo "select count(1) from master.sys.objects with(nolock) where name like '$1%'" | isql dsn_name user_name pass_word
@kjakka
kjakka / macos-vpn.md
Last active August 26, 2019 19:19
getting macos to use IPSec VPN with cert