Skip to content

Instantly share code, notes, and snippets.

@gauravv7
gauravv7 / .block
Last active September 1, 2019 16:21
Text on an Arc - Animal Donut Slices - Flipped & Centered Arc Labels
license: mit
# curl -sL bit.ly/p7virtualenv | bash
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.5.tar.gz
tar xzf virtualenv-12.0.5.tar.gz && rm virtualenv-12.0.5.tar.gz
mv virtualenv-12.0.5 ~/.virtualenv
echo >> ~/.bashrc
echo "alias virtualenv='python $HOME/.virtualenv/virtualenv.py'" >> ~/.bashrc
echo 'Now run: source ~/.bashrc'
@gauravv7
gauravv7 / scipt.js
Created March 22, 2019 08:24
get google cell background color hex code
function getHex(input) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var cell = ss.getRange(input);
var result = cell.getBackground();
return result
}
@gauravv7
gauravv7 / django_pretty_request.py
Created November 28, 2018 11:32
a good way to print django request details
def pretty_request(request):
headers = ''
for header, value in request.META.items():
if not header.startswith('HTTP'):
continue
header = '-'.join([h.capitalize() for h in header[5:].lower().split('_')])
headers += '{}: {}\n'.format(header, value)
return (
'{method} HTTP/1.1\n'
/**
* issue #52(hot fix)
* the below code is to replace the DomNodeInserted JQuery block code(django-easy-selectv1.5.3/easy-select2.js) with below implementation as it is.
* this implementation is confirmed for issue-52
* (currently in performance testing to make a production release for this implementation)
*/
// Select the node that will be observed for mutations
var targetNode = document.documentElement || document.body;
@gauravv7
gauravv7 / init.js
Created June 3, 2018 13:08
ajaxified easy_select calls
// sample property callback for select2 constructor argument
function formatState (state) {
var baseUrl = "http://lorempixel.com/4/4/";
var $state = $(
'<span><img src="' + baseUrl + '" class="img-flag" /> ' + (state.title || state.text)+ '</span>'
);
return $state;
};
function formatTodo (repo) {
if (repo.loading) {
@gauravv7
gauravv7 / admin.py
Created April 28, 2018 05:11
django-easy-select2==1.4.0 | adding image in options tags
# // https://github.com/asyncee/django-easy-select2/tree/master/sampleproject
# sampleproject/demoapp/admin.py
from django.contrib import admin
from django.db import models
from easy_select2 import Select2
from easy_select2.widgets import SELECT2_WIDGET_JS
from .models import Note, Category
Sep 12 15:07:27 hostname kernel: [ 8622.614779] vgaarb: this pci device is not a vga device
Sep 12 15:07:57 hostname wpa_supplicant[1554]: wlan0: CTRL-EVENT-SCAN-STARTED
Sep 12 15:09:00 hostname wpa_supplicant[1554]: wlan0: CTRL-EVENT-SCAN-STARTED
Sep 12 15:09:01 hostname CRON[16411]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Sep 12 15:10:23 hostname wpa_supplicant[1554]: wlan0: CTRL-EVENT-SCAN-STARTED
Sep 12 15:16:06 hostname wpa_supplicant[1554]: message repeated 4 times: [ wlan0: CTRL-EVENT-SCAN-STARTED ]
Sep 12 15:17:01 hostname CRON[16509]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Sep 12 15:17:03 hostname wpa_supplicant[1554]: wlan0: CTRL-EVENT-SCAN-STARTED
Sep 12 15:19:28 hostname kernel: [ 9344.462540] vgaarb: this pci device is not a vga device
Sep 12 15:18:06 hostname wpa_supplicant[1554]: wlan0: CTRL-EVENT-SCAN-STARTED
@gauravv7
gauravv7 / git-mv-with-history
Created May 5, 2017 12:51 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@gauravv7
gauravv7 / input.scss
Created December 29, 2016 08:52 — forked from lukasborawski/input.scss
Perfect media-queries screen breakpoints SASS @mixin. Tested on Apple Devices: iPhone4, iPhone5, iPad3, MacBook Pro, iPad Mini. http://sassmeister.com/gist/8529371
$media-queries: true;
@mixin bp($point) {
@if ($media-queries) {
$bp-large-screen: 1824px;
$bp-bigscreen: 1824px;
$bp-ipad-max: 1024px;
$bp-ipad-min: 768px;
$bp-iphone5-max: 568px;
$bp-iphone-max: 480px;