Skip to content

Instantly share code, notes, and snippets.

@kvahuja
kvahuja / SpinWords
Created May 13, 2021 20:57
Code Wars Kata - Spinwords
public final class SpinWords {
public String spinWords(String sentence) {
String[] words = sentence.split(" ");
for (int i = 0; i < words.length; i++) {
// for each word
String word = words[i];
if (word.length() >= 5) {
@kvahuja
kvahuja / setup-user.MD
Last active November 27, 2017 08:06
Ubuntu Management - Server Setups

User Setup

Add a User

Run the following command to add a new user on a system.

sudo adduser <username>
@kvahuja
kvahuja / Items.php
Created March 4, 2017 04:55
Vainglory Items
<?php
return [
'*1000_Item_HalcyonPotion*' => 'halcyon-potion',
'Mulled Wine' => 'halcyon-potion',
'*1002_Item_WeaponBlade*' => 'weapon-blade',
'Weapon Blade' => 'weapon-blade',
'*1003_Item_CrystalBit*' => 'crystal-bit',
'Crystal1' => 'crystal-bit',
@kvahuja
kvahuja / Heros.php
Last active April 1, 2017 09:34
Vainglory API - Mappings
<?php
return [
'*Adagio*' => 'Adagio',
'*Alpha*' => 'Alpha',
'*Ardan*' => 'Ardan',
'*Baron*' => 'Baron',
'*Blackfeather*' => 'Blackfeather',
'*Catherine*' => 'Catherine',
@kvahuja
kvahuja / db-connect-check.php
Created February 27, 2017 04:53
PHP DB Connect Check
<?php
# To run this script use the following command on cli (we assume you have all dependencies installed)
# only checks for mysql for now
# $ php -f db-connect-check.php
$dbhost = 'host';
$dbport = '3306'
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
@kvahuja
kvahuja / Info.php
Created February 27, 2017 04:47
Check PHP Installation
<?php
phpinfo();
?>
@kvahuja
kvahuja / pg_dump.sh
Created February 10, 2017 05:07
PgSQL Commands
# how to generate a dump for postgres
pg_dump --file "dmp.filename.ext" --host "hostname" --port "5432" --username "myusername" --password "changeme" --verbose --role "dbname" --format=c
@kvahuja
kvahuja / Select all occurences of a text
Created February 7, 2017 06:03
Sublime Key Mappings
Alt+F3
@kvahuja
kvahuja / scp-upload-file.sh
Last active February 7, 2017 04:57
Shell Cheat Sheet
scp -i folder/where/private/key/is/placed/key-name.ppk -r source/folder/in/local.machine/* username@host:/folder/in/remote/machine/
@Aspect
public class ProfilingAspect {
@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
StopWatch sw = new StopWatch(getClass().getSimpleName());
try {
sw.start(pjp.getSignature().getName());
return pjp.proceed();
} finally {