Skip to content

Instantly share code, notes, and snippets.

function hexToRgb(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
@vivekvasani
vivekvasani / instructions.md
Created March 18, 2020 20:21 — forked from douglasmiranda/instructions.md
Add email to Keybase.io PGP Key (Public Key)

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret > keybase-private.key
@vivekvasani
vivekvasani / index.js
Created July 7, 2017 15:53
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const Joi = require('joi');
const categoryConfigSchema = Joi.object().keys({
contentTypes: Joi.array().items(Joi.string()).default([]),
minSelected: Joi.number().integer().min(0).default(0),
maxSelected: Joi.number().integer().min(-1).default(-1),
@vivekvasani
vivekvasani / script.sh
Last active May 14, 2017 18:55
test script
#!/bin/sh
echo -e "this is revision 5"

Keybase proof

I hereby claim:

  • I am vivekvasani on github.
  • I am vivekvasani (https://keybase.io/vivekvasani) on keybase.
  • I have a public key ASBwNY1bXlLYQEZHXiM6mV5Iq16oaFJPlS48YmrgEnxcOgo

To claim this, I am signing this object:

@vivekvasani
vivekvasani / bulk-resize-script
Last active August 29, 2015 00:33 — forked from MikeNGarrett/bulk-resize-script
Imagemagick recursively reduce files to < 800x600 and 72ppi
# This is a bash script meant to be run on the command line. Requires imagemagick (apt-get install imagemagick)
## THIS WILL OVERWRITE YOUR FILES, uses sudo and may not require it.
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 $file; done
### another method using resolution (800*600)
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '480000@>' -density 72 $file; done
### example of *not* overwriting files
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 converted-$file; done
#!/bin/sh
#
# Orinally made by Lovell Fuller for sharp
# https://github.com/lovell/sharp
#
# Usage:
# curl -s https://gist.githubusercontent.com/vivekvasani/4dab3ff0f505fe4b2027/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash -
#
@vivekvasani
vivekvasani / Base-SDK-Check.m
Created December 17, 2013 22:13
Check if Base SDK is set to desired SDK version and throw error if it doesn't match. I put this in my *.pch file.
// Check if Base SDK is set to desired SDK version and throw error if it doesn't match
#if __IPHONE_OS_VERSION_MAX_ALLOWED != __IPHONE_6_1
#error App should be built using iOS 6.1 SDK
#else
#endif
- (void)main
{
[self doStuffInOperations];
}
- (void)doStuffInGCD
{
dispatch_group_t d_group = dispatch_group_create();
dispatch_queue_t bg_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);