Skip to content

Instantly share code, notes, and snippets.

View vikynandha-zz's full-sized avatar

Vignesh Nandha Kumar vikynandha-zz

View GitHub Profile
;;; auto-remove.el --- Auto remove unused functions in python
;;; Commentary:
;; Uses external tool autoflake to remove unused imports from a Python file.
;;; Code:
(defcustom python-autoflake-path (executable-find "autoflake")
"Autoflake executable path.
@hdragomir
hdragomir / sm-annotated.html
Last active June 13, 2024 03:01
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@vikynandha-zz
vikynandha-zz / format-file-size.js
Last active December 25, 2015 00:28
Format file size in bytes to human-readable string
function fileSizeFormat( num_bytes ) {
if ( ! num_bytes ) return '0 bytes';
typeof num_bytes == 'number' || ( num_bytes = parseFloat( num_bytes ) );
if ( isNaN( num_bytes ) ) return '';
var i = -1;
var byteUnits = [ 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
do {
num_bytes = num_bytes / 1000;
i++;
@unicodefreak
unicodefreak / gist:1901458
Created February 24, 2012 14:59
Include tag for underscore template
// based on http://emptysquare.net/blog/adding-an-include-tag-to-underscore-js-templates/
// include tag for underscore templates
// <% include template-id %>
var _underscore_template = _.template;
_.template = function(str, data) {
// match "<% include template-id %>"
return _underscore_template(
str.replace(
/<%\s*include\s*(.*?)\s*%>/g,
@bentruyman
bentruyman / slug.js
Created September 12, 2011 14:31
JavaScript Slug Generator
// Generates a URL-friendly "slug" from a provided string.
// For example: "This Is Great!!!" transforms into "this-is-great"
function generateSlug (value) {
// 1) convert to lowercase
// 2) remove dashes and pluses
// 3) replace spaces with dashes
// 4) remove everything but alphanumeric characters and dashes
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
};