Skip to content

Instantly share code, notes, and snippets.

View Trshant's full-sized avatar
🤠
docker/kubernetes/

Trshant Trshant

🤠
docker/kubernetes/
View GitHub Profile
@Trshant
Trshant / VBA
Created November 11, 2013 05:33
A friend wanted a way to make folders for every day of the year 2012. Made one in python. Another suggested that VBA script is a nicer alternative. This is my first VBA script, Learnt and Written on the fly :)
Set objFSO = CreateObject("Scripting.FileSystemObject")
y = ""
MyDate = DateSerial(2012, 1, 1)
y = year(MyDate)*10000+month(MyDate)*100+day(MyDate)
WScript.echo y
objFSO.CreateFolder y
For counterVariable = 1 to 366
@Trshant
Trshant / AutomatedFolderCreation_py
Created November 11, 2013 05:41
Made a Python script which automates folder creation, each named for ever day of the year like 01012012.....01022012, 02022012.....31122012.
from datetime import datetime , timedelta
import os
dt_obj = datetime(2012, 1, 1, 17, 53, 59)
for i in range(0,366):
dt_obj2 = dt_obj + timedelta(days=i)
os.makedirs( dt_obj2.strftime("%Y%m%d") )
print "done"
@Trshant
Trshant / movie.html
Last active August 29, 2015 14:08
A movie detail viewer.
<!DOCTYPE html>
<html>
<head>
<title>Movie Info</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="https://code.angularjs.org/1.2.16/angular-route.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=trshant" async="async"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/min/1.5/min.min.css">
@Trshant
Trshant / Ethnicity.html
Last active April 24, 2019 16:26
http://en.wikipedia.org/wiki/List_of_contemporary_ethnic_groups <- List for ethnicity groups. Code to extract data is below the resulting HTML.
<select name="">
<option value="Han Chinese">Han Chinese</option>
<option value="Hindustani">Hindustani</option>
<option value="Arabs">Arabs</option>
<option value="Bengalis">Bengalis</option>
<option value="Germans">Germans</option>
<option value="Spaniards">Spaniards</option>
<option value="Italians">Italians</option>
<option value="Japanese">Japanese</option>
<option value="Russians">Russians</option>
@Trshant
Trshant / Ethnicity list HTML dropdown
Created March 16, 2015 07:24
This is the hTML code for a ethnicity dropdown. The list is taken from http://en.wikipedia.org/wiki/List_of_contemporary_ethnic_groups . https://gist.github.com/Trshant/180328441d285549144f - code used for extracting the data from the html page.
<select name="">
<option value="Han Chinese">Han Chinese</option>
<option value="Hindustani">Hindustani</option>
<option value="Arabs">Arabs</option>
<option value="Bengalis">Bengalis</option>
<option value="Germans">Germans</option>
<option value="Spaniards">Spaniards</option>
<option value="Italians">Italians</option>
<option value="Japanese">Japanese</option>
<option value="Russians">Russians</option>
@Trshant
Trshant / mouseposition
Created June 2, 2015 05:52
This will get the mouse position in javascript.
var position = {};
document.addEventListener('mousemove', function(e){
position = { x: e.clientX, y: e.clientY } // for browser window WRT
position = { x: e.pageX, y: e.pageY } // for page WRT
});
@Trshant
Trshant / getLatLng.js
Created September 2, 2015 13:55
To get the latitude and longitude of the place by using the browser
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
console.log( latitude , longitude );
})
@Trshant
Trshant / print js
Created March 22, 2016 08:30
Detecting Print Requests with JavaScript
(function() {
var beforePrint = function() {
console.log('Functionality to run before printing.');
};
var afterPrint = function() {
console.log('Functionality to run after printing');
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
string <- "Hello World"
string
@Trshant
Trshant / ipak.R
Created September 8, 2016 13:24 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}