Skip to content

Instantly share code, notes, and snippets.

@tnip
tnip / verticallyAlignTheDamnThing()
Created July 9, 2012 03:02
Vertically Centering Things in JS
function verticallyAlignTheDamnThing(){
var content_height = $(‘#centered-element’).height();
var window_height = $(document).height();
// Reposition the div vertically!
var reposition_top_y = (window_height - content_height) / 2;
if(reposition_top_y > 0){
$(‘#centered-element’).css(‘margin-top’, reposition_top_y + ‘px’);
}
}
@tnip
tnip / weather
Created July 19, 2013 01:30
because i don't like switching apps to get the weather [update] it's also here if you want it/want to bug me about it: https://github.com/tnip/miscellaneous/blob/master/weather
weather(){
# Usage:
# weather 13210
# weather syracuse ny
# weather "new york" ny
# weather nyc
if [ $2 ]
then
1=$(echo "$1" | sed -e "s/ /_/g")
import os
import sys
if len(sys.argv) < 2:
print('Usage: python setup.py <netid>')
sys.exit(0)
netid = sys.argv[1]
os.system('sudo echo kernel.randomize_va_space = 0 > /etc/sysctl.d/01-disable-aslr.conf')
@tnip
tnip / test.js
Last active September 2, 2015 23:29
function foo() {
alert("fdf");
}
@tnip
tnip / main.dart
Last active March 25, 2019 19:50
bool hasDoubleDecker(values) {
if (values == null || values.length < 5) {
return false;
}
for (var i = 0; i < values.length - 4; i++) {
if (values[i] == values[i + 2] &&
values[i] == values[i + 4] &&
values[i + 1] == values[i + 3]) {
return true;
void main() {
List<String> ourList = ['a', 'b', 'c'];
for (int i = 0; i < ourList.length; i++) {
print(ourList[i]);
}
}