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 / extract ethnic groups
Last active November 8, 2024 05:32
http://en.wikipedia.org/wiki/List_of_contemporary_ethnic_groups <- List for ethnicity groups. Code to extract data is below the resulting HTML.
var rows = $('table.wikitable tr') ;
rowlen = rows.length ;
rrr = [] ;
for( i=1 ; i<rowlen ; i++ ){
row = rows[i];
var v = $(row).find('td a')[0].innerHTML ;
//alert( v );
rrr.push( v );
}
select_string = '<select name="">\n';
@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)
}
@Trshant
Trshant / RoundingToNextTop.php
Last active September 9, 2016 12:01
This gives the number rounded off the next biggest integer. Please see beneath the definition to see what i mean
<?php
function RoundingToNextTop( $num , $rounding ) {
return ( round( $num , (-1 * $rounding ) ) < $num )? round( $num , (-1 * $rounding ))+pow ( 10 , $rounding ) : round( $num , (-1 * $rounding ) ) ;
}
echo RoundingToNextTop( 13.3583 , 1 ) ;
// 20
echo RoundingToNextTop( 103.3583 , 1 ) ;
// 110
echo RoundingToNextTop( 103.3583 , 2 ) ;