Skip to content

Instantly share code, notes, and snippets.

@shane-edmonds
shane-edmonds / pandas_dataframe_date_splitting.py
Created April 23, 2020 19:40
Pandas DataFrame Date Splitting
#pandas datetimeindex docs: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DatetimeIndex.html
#efficient way to extract year from string format date
df['year'] = pd.DatetimeIndex(df['birth_date']).year
df.head()
#pandas datetimeindex docs: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DatetimeIndex.html
df['month'] = pd.DatetimeIndex(df['birth_date']).month
df.head()
#if the date format comes in datetime, we can also extract the day/month/year using the to_period function
@shane-edmonds
shane-edmonds / gist:7966728
Created December 15, 2013 00:00
You can use the File.ReadLines Method to read the file line-by-line without loading the whole file into memory at once, and the Parallel.ForEach Method to process the lines in multiple threads in parallel.
Parallel.ForEach(File.ReadLines("file.txt"), (line, _, lineNumber) =>
{
// processing code here
});
@shane-edmonds
shane-edmonds / gist:5655039
Created May 27, 2013 03:27
Android style "Holo" loader with Pure CSS
/*
<div class="loading">
<div class="outer"></div>
<div class="inner"></div>
</div>
*/
/* Loading indicator */
.loading {
position: relative;
@shane-edmonds
shane-edmonds / gist:5655033
Created May 27, 2013 03:24
Pure CSS Spinner with Only One DOM Element
/*
<div class="spinner"></div>
*/
.spinner {
height:60px;
width:60px;
margin:0 auto;
position:relative;
-webkit-animation: rotation .6s infinite linear;
@shane-edmonds
shane-edmonds / gist:5562649
Created May 12, 2013 06:35
PowerShell Function Template
function new-template {
<#
.SYNOPSIS
Brief description of what the function does
.DESCRIPTION
A better description
.NOTES
Function Name : new-template
Author : Adam Stone
Requires : PowerShell V2
@shane-edmonds
shane-edmonds / timer.html
Created November 12, 2012 19:02
CSS Visual Spinner Countdown Timer
<!DOCTYPE html>
<html>
<head>
<style>
.circle-timer, .pie-timer {
width: 220px;
height: 220px;
position: relative;
box-shadow: #ccc 0 0 25px;
@shane-edmonds
shane-edmonds / GenericCallHandler.xml
Created June 20, 2012 18:13
Generic TwiML Call Handler
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>Hello World</Say>
</Response>