Skip to content

Instantly share code, notes, and snippets.

View virenratan's full-sized avatar

Viren virenratan

  • Melbourne, AU
View GitHub Profile
@virenratan
virenratan / Package Control.sublime-settings
Last active April 11, 2016 01:29
Sublime Text 2 - Preferences
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"AngularJS",
"BracketHighlighter",
"DocBlockr",
@virenratan
virenratan / contenteditable.js
Created May 6, 2014 03:13
Contenteditable element which respects maxlength attribute
app.directive('contenteditable', ['$timeout', function($timeout) {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel',
scope: { model: '=ngModel' },
link: function(scope, element, attrs, ngModelCtrl) {
if( !ngModelCtrl ) return;
// model -> view
ngModelCtrl.$render = function() {
@virenratan
virenratan / app.js
Created May 6, 2014 04:45
Lazyload images as background-image's, with spinner and updating classes during loading
var app = angular.module('lazy', []);
app.controller('MainCtrl', function($scope) {
$scope.test = 'https://www.filepicker.io/api/file/FueFmlDQ7iLU1HRGmMSx/convert?w=550&h=550&fit=crop';
});
app.directive('lazyBackground', ['$document', '$parse', function($document, $parse) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
@virenratan
virenratan / backup.js
Last active August 29, 2015 14:01
update form $error object if api call generates validation errors
// backing up the return from the api
var backup;
Service.get({id: $scope.someValue}, function success(data) {
backup = angular.copy( data.projects );
});
@virenratan
virenratan / init.coffee
Last active September 19, 2018 04:15
Atom editor config
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@virenratan
virenratan / cloudSettings
Last active March 17, 2021 02:53
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-03-17T02:52:54.762Z","extensionVersion":"v3.4.3"}
@virenratan
virenratan / install.sh
Created April 30, 2018 06:30 — forked from mshick/install.sh
Installing Node.js with Homebrew and nvm
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install nvm
brew install nvm
# Export nvm environment
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
@virenratan
virenratan / twitter-cleanup.js
Created July 14, 2018 02:52
Delete twitter content
// delete tweets.
[].slice.call(document.getElementsByClassName('js-actionDelete')).map(tweet => {
tweet.childNodes[1].click()
document.getElementsByClassName('delete-action')[0].click()
})
// un-retweet.
[].slice.call(document.getElementsByClassName('ProfileTweet-actionButtonUndo')).map(retweet => {
retweet.click()
document.getElementsByClassName("js-close")[0].click()
@virenratan
virenratan / gist:5226d6667a37ddefbbe94e1ddfca2b33
Created September 19, 2018 01:01 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@virenratan
virenratan / macos-doh-cloudflare.md
Created September 19, 2018 06:55
macOS DoH (DNS over HTTPS) using cloudflare DNS servers
brew install dnscrypt-proxy

Edit /usr/local/etc/dnscrypt-proxy.toml and edit server_names

server_names = ['cloudflare']

Then just start it and ensure it starts on boot

sudo brew services start dnscrypt-proxy