Skip to content

Instantly share code, notes, and snippets.

View himanshub16's full-sized avatar
💭
Might be slow to respond

Himanshu Shekhar himanshub16

💭
Might be slow to respond
View GitHub Profile
@himanshub16
himanshub16 / ProcessState.java
Created August 10, 2019 15:56
Get CPU percent of a process using sigar (java)
/*
* Copyright (c) 2006 Hyperic, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@himanshub16
himanshub16 / code.cpp
Last active June 7, 2018 03:22
C++ Literal suffix behavior
#include <iostream>
using namespace std;
int main()
{
// Likely to generate a warning.
unsigned long long limit63bit = 18446744073709551615; // 2^64 - 1
// OK
@himanshub16
himanshub16 / padifsc.js
Created April 18, 2018 14:22
Script to convert integer IFSC codes to string in Razorpay's IFSC database
const ifsc = require('./IFSC')
const fs = require('fs')
const validate = require('./node/index').validate
const ifsc_size = 7
let newIfsc = {}
function pad(n, width, z) {
z = z || '0'
@himanshub16
himanshub16 / streaming-api.go
Created March 6, 2018 20:18
Simple streaming API in Go
package main
import (
"compress/gzip"
"fmt"
"net/http"
"time"
)
func main() {
@himanshub16
himanshub16 / scan-files.js
Created February 25, 2018 17:57
Find N largest files in a directory (searches recursively)
const fs = require('fs');
const path = require('path');
function scanDirectory(dirpath, allFiles) {
// nodejs runs single threaded, so is thread-safe.
// NO MUTEX. MISSION ACCOMPLISHED YAYY
if (dirpath.fullpath !== undefined) {
dirpath = dirpath.fullpath;
@himanshub16
himanshub16 / desktop-cleaner.js
Created February 25, 2018 17:56
Find files on your desktop and send them elsewhere (clustered by extension)
const fs = require('fs');
const path = require('path');
const homedir = require('os').homedir;
function scanDirectory(dirpath, allFiles) {
// nodejs runs single threaded, so is thread-safe.
// NO MUTEX. MISSION ACCOMPLISHED YAYY
@himanshub16
himanshub16 / dabblet.css
Created September 23, 2016 10:56 — forked from LeaVerou/dabblet.css
Text-underline-animation
/**
* Text-underline-animation
*/
a {
font-size: 500%;
text-decoration: none;
background: linear-gradient(currentColor, currentColor) bottom / 0 .1em no-repeat;
transition: 1s background-size;
}
@himanshub16
himanshub16 / ftpsize.py
Last active July 15, 2016 16:04 — forked from albertyw/ftpsize.py
Script to find the total size of an ftp directory by recursively opening directories
"""
This script finds the total size of an ftp directory by recursively opening directories
@author: Albert Wang (albertyw@mit.edu)
September 18, 2010
"""
"""
Changes made by Himanshu Shekhar (https://github.com/himanshub16)
-----------------------------------------------------------------------
* OptionsParser added instead of sys.argv
* Support for port added for ftp client