Skip to content

Instantly share code, notes, and snippets.

@superkarn
superkarn / update-lock-screen-timeout.bat
Created May 12, 2019 02:38
This script will change Windows' lock screen timeout to 500 seconds.
REM This script will change Windows' lock screen timeout to 500 seconds.
powercfg.exe /SETACVALUEINDEX SCHEME_CURRENT SUB_VIDEO VIDEOCONLOCK 500
powercfg.exe /SETACTIVE SCHEME_CURRENT
@superkarn
superkarn / flattenArray.js
Last active October 24, 2018 14:38
A javascript to flatten arbitrarily nested arrays
//////////////////////////////
// Problem:
// Flatten an array of arbitrarily nested arrays of integers
// into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
// Solution one
let flattenArray = (a) => {
// If a is not an array, throw an error
if (!Array.isArray(a)) {
@superkarn
superkarn / SQL - Random number in a query.sql
Last active July 19, 2018 20:53
Generate random number in a query
-- https://stackoverflow.com/a/5003054
-- Generate a random number: 0= < x < 60
-- One random number per row of data.
select abs(checksum(newid()) % 60)

Keybase proof

I hereby claim:

  • I am superkarn on github.
  • I am superkarn (https://keybase.io/superkarn) on keybase.
  • I have a public key ASBLXpAy-DvKbi-E1P26iDOMkt90ehzIxns6uGbhzGWf5Qo

To claim this, I am signing this object:

@superkarn
superkarn / edit-hosts-file.ps1
Last active September 4, 2017 18:38
This will open the hosts file using notepad so that you can edit it.
# This will open the hosts file using notepad so that you can edit it.
# Open PowerShell or command line with Administrator privileges
# Run the following command
notepad "C:\WINDOWS\system32\drivers\etc\hosts"
@superkarn
superkarn / SecureRequestFilterAttribute.cs
Created October 22, 2012 18:59
This attribute forces a particular request to be secure (over SSL).
public class SecureRequestFilterAttribute : Attribute, IHasRequestFilter
{
public IHasRequestFilter Copy()
{
return this;
}
public int Priority
{
// https://github.com/ServiceStack/ServiceStack/issues/119
@superkarn
superkarn / test.cs
Created September 16, 2010 15:25
test gist
#region Test
// test
int a = 0;
#endregion