Skip to content

Instantly share code, notes, and snippets.

View brunosan's full-sized avatar

Bruno Sánchez-Andrade Nuño brunosan

View GitHub Profile
@brunosan
brunosan / gist:1596420
Created January 11, 2012 19:49
Implicit functions are cool, but SLOW in VB Excel.
Public Sub ExtrapolateInput()
Dim xCell As Range
Dim i As Range
Dim country As Integer
CurrentPath = ActiveWorkbook.Path
' Extend forward last Value and backwards first Value
@brunosan
brunosan / gist:1714673
Created February 1, 2012 02:27
MacBook Air Battery health after one year of daily use
Via "Coconut battery" app
MacBook Air.
Battery capacity 92% of new battery (4680 mAh)
Load Cycles: 309
Age: 13 months.
Capacity.
Using Wifi and surfing the web and light bittorrent. Screen at 75% bright
2 CPU Typical load averages: 1.68 1.48 1.27
@brunosan
brunosan / gist:1935004
Created February 28, 2012 20:46
Backup of the working code in VBA.
Option Explicit
Public FirstYearCol As Integer
Public LastYearCol As Integer
Public NumberOfYears As Integer
Public FirstCountryRow As Integer
Public LastCountryRow As Integer
Public NumberOfCountries As Integer
Public NumberOfMeasures As Integer
Public FirstYear As Integer
@brunosan
brunosan / USB_copier.sh
Created May 8, 2012 20:49
Say you need to put some files on 100 USB sticks...
#!/bin/sh
for i in {1..999}
do
echo "Waiting for some love"
while [ ! -s /Volumes/USB\ DISK/ ]
do
sleep 0.5
printf "."
done
@brunosan
brunosan / gist:2727042
Created May 18, 2012 18:56
Simple Token Generation
=Join("",CHAR(C2),A2,Char(B2),dec2oct(B2))
A2 is a cell with the ID of the person
B2 and C2 are Random (but static) numbers.
Examples:
ids random random token
2 109 117 u2m155
3 121 115 s3y171
4 102 108 l4f146
5 111 118 v5o157
@brunosan
brunosan / gist:2727107
Created May 18, 2012 19:11
Main loop process invitations
function ProcessList() {
sendEmail =0 ;
// Track remaining email quota.
var budget = MailApp.getRemainingDailyQuota();
// For every person
for (var i = 0; i < data.length; ++i) {
if (budget < 0){
Browser.msgBox("Sorry, your account has reached your daily quote of emails.")
break;
@brunosan
brunosan / gist:2727146
Created May 18, 2012 19:20
Send Email
var message = "<HTML><BODY>"
+ '<img align="middle" width="150px" src="http://gain.org/images/gainlogo.png"><br>'
+ "<br><p align='left'> April "+Utilities.formatDate(new Date(), 'GMT', 'd, yyyy')+"</p>"
+ "<br><p>Dear " + row.prefix + " " + row.lastName + ", <p> "
+ '<P>It is an honor to invite you to ...REST OF EMAIL'
+ ' Please RSVP at your <a href="'
+ construct_URL(row)
+ '"> personalized form</a>. </p>'
+ '<P> REST OF EMAIL'
+ "</HTML></BODY>";
@brunosan
brunosan / gist:2727214
Created May 18, 2012 19:32
Construct URL
function construct_URL(row)
{
switch(row.group)
{
case 1:
var RESPONSES_URL = RESPONSES_GROUP1_URL;
var AUTOFILL = "&entry_6="+ (row.prefix|| " ")
+ "&entry_0="+row.firstName
+ "&entry_7="+row.lastName
+ "&entry_8="+(row.company || " ")
@brunosan
brunosan / gist:2727230
Created May 18, 2012 19:35
Process Reply
function readReplies(row) {
// Open the Responses Spreadsheet and fetch responses.
switch(row.group)
{
case 1:
ReplyData = ReplyData1; // This comes from getRowsData(Group1Sheet);
break;
default:
ReplyData = ReplyData2;
}
@brunosan
brunosan / gist:2727260
Created May 18, 2012 19:42
Update Info
function updateInfo(row,reply,column,fieldanswer) {
var current= sheet.getRange(row.id+2, column).getValue();
var updated= (fieldanswer || current);
if (current != updated) {
// update field
sheet.getRange(row.id+2, column).setValue(updated);
sheet.getRange(row.id+2, column).setBackgroundColor('green');
}