Skip to content

Instantly share code, notes, and snippets.

View Lwdthe1's full-sized avatar

Lincoln W Daniel Lwdthe1

View GitHub Profile
@Lwdthe1
Lwdthe1 / jquery.setDoubleTap.js
Last active May 9, 2016 20:27
A simple jQuery function to capture double tap (or click) event on an element.
(function($){
$.fn.setDoubleTap = function(doubleTap){
var lastTapTime;
var doDoubleTap = function() {
//set the time of this click
var timeNow = new Date().getTime();
//calculate the time since last click
var timeSinceLastTap = timeNow - lastTapTime;
//check if it's been long enough to deem this click a part of a double tap sequence
@Lwdthe1
Lwdthe1 / PhotoScalerAndSaver.java
Last active January 15, 2022 02:03
A demonstration of three Java functions for scaling a photo's bitmap and saving it to a file without contorting the photo's dimensions. This is in response to this stackoverflow question: http://stackoverflow.com/questions/16060143/android-take-photo-and-resize-it-before-saving-on-sd-card/36210688#36210688
public class PhotoScalerAndSaver {
public static main(String[] args) {
//TODO: create your photo here
//Convert your photo to a bitmap
Bitmap photoBm = (Bitmap) "your Bitmap image";
//scale and save the photo to a file on the directory
saveScaledPhotoToFile(Bitmap photoBm)
@Lwdthe1
Lwdthe1 / License.txt
Last active March 31, 2016 22:28
A jQuery function to run a function when an element is long pressed
DO WHATEVER YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Lincoln W Daniel <http://lincolnwdaniel.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@Lwdthe1
Lwdthe1 / License.txt
Last active March 31, 2016 22:30
A jQuery function to add a actionable child element (the hider) to a parent element (the hidee). When clicked, the hider will hide the hidee. Raw
DO WHATEVER YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Lincoln W Daniel <http://lincolnwdaniel.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@Lwdthe1
Lwdthe1 / License.txt
Last active March 31, 2016 22:30
A jQuery function used to check if a html element's parent div has a light background-color (or "background").
DO WHATEVER YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Lincoln W Daniel <http://lincolnwdaniel.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@hirenrojasara
hirenrojasara / Drop index from mongoose model programatically.js
Last active April 26, 2021 09:30
Drop index from mongoose model programatically
// If you are having multiple mongoose connection, please iterate it and get the reference.
mongoose.connections[0].collections("collectionname").dropIndex("propertyName",callback)
@Stoffo
Stoffo / remove_documents_mongodb.js
Created October 29, 2015 12:29
Remove Documents older than x days in MongoDB
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@Miserlou
Miserlou / cities.json
Created April 30, 2015 06:58
1000 Largest US Cities By Population With Geographic Coordinates, in JSON
[
{
"city": "New York",
"growth_from_2000_to_2013": "4.8%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": "8405837",
"rank": "1",
"state": "New York"
},
@minorbug
minorbug / timeago.swift
Created November 7, 2014 15:28
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C)
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String {
let calendar = NSCalendar.currentCalendar()
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond
let now = NSDate()
let earliest = now.earlierDate(date)
let latest = (earliest == now) ? date : now
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil)
if (components.year >= 2) {
return "\(components.year) years ago"
@patriciogonzalezvivo
patriciogonzalezvivo / PythonSetup.md
Created October 7, 2014 23:17
How to install Python correctly on Mac OSX

Install Homebrew

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Add PATH to ~/.bash_profile and ~/.zshrc

export PATH=/usr/local/bin:$PATH