Skip to content

Instantly share code, notes, and snippets.

View eddieespinal's full-sized avatar

Eddie Espinal eddieespinal

View GitHub Profile
@nzjrs
nzjrs / datedifference.py
Created October 11, 2009 11:38
Humanize date differences
#!/usr/bin/env python
# This function prints the difference between two python datetime objects
# in a more human readable form
#
# Adapted from: http://www.chimeric.de/blog/2008/0711_smart_dates_in_python
def humanize_date_difference(now, otherdate=None, offset=None):
if otherdate:
dt = otherdate - now
offset = dt.seconds + (dt.days * 60*60*24)
@boucher
boucher / StripeTutorialPage.html
Created February 6, 2012 07:05
Stripe Tutorial Payment Form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
// this identifies your website in the createToken call below
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@planetoftheweb
planetoftheweb / insertyoutubefeed
Created April 12, 2012 14:18
Insert YouTube Channel Feed & Player into any site using JSON
<style>
#videogroup {
width: 100%;
}
iframe {
width: 90%;
padding: 5%;
}
@sanketss84
sanketss84 / gist:3515926
Created August 29, 2012 17:32
Arduino RealTime Clock Set Time
#include "Wire.h"
#define DS1307_ADDRESS 0x68
void setup(){
Wire.begin();
Serial.begin(9600);
setDateTime(); //MUST CONFIGURE IN FUNCTION
}
void loop(){
@sanketss84
sanketss84 / gist:3515941
Created August 29, 2012 17:33
Arduino RealTime Clock Serial Output
#include "Wire.h"
#define DS1307_ADDRESS 0x68
int alarmPin = 12;
void setup(){
Wire.begin();
Serial.begin(9600);
pinMode(alarmPin, OUTPUT); //alarmPin
}
@Supraman
Supraman / CSM
Created November 13, 2012 19:57
Arduino Clock with set menu
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal.h>
#include <LCDKeypad.h>
LCDKeypad lcd;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
@marcuswestin
marcuswestin / ios getIpAddress
Created February 10, 2013 03:13
get IP address of iOS device
static NSString* getAddress() {
id myhost =[NSClassFromString(@"NSHost") performSelector:@selector(currentHost)];
if (myhost) {
for (NSString* address in [myhost performSelector:@selector(addresses)]) {
if ([address rangeOfString:@"::"].location == NSNotFound) {
return address;
}
}
}
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@ronivaldo
ronivaldo / rpmLargeFont.ino
Created May 15, 2013 21:02
A set of custom made large numbers for a 16x2 LCD HD44780 Arduino Library
/*
A set of custom made large numbers for a 16x2 LCD using the
LiquidCrystal librabry. Works with displays compatible with the
Hitachi HD44780 driver.
The Cuicuit:
LCD RS pin to D12
LCD Enable pin to D11
LCD D4 pin to D5
LCD D5 pin to D4