Skip to content

Instantly share code, notes, and snippets.

Santiago Valdarrama svpino

Block or report user

Report or block svpino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View s3-lambda-related-files.py
@svpino
svpino / last_five_business_days.sql
Created Dec 18, 2015
How to determine last 5 business days in BigQuery
View last_five_business_days.sql
select date
from
(select date_add(current_date(), -1, "DAY") as date),
(select date_add(current_date(), -2, "DAY") as date),
(select date_add(current_date(), -3, "DAY") as date),
(select date_add(current_date(), -4, "DAY") as date),
(select date_add(current_date(), -5, "DAY") as date),
(select date_add(current_date(), -6, "DAY") as date),
(select date_add(current_date(), -7, "DAY") as date)
where dayofweek(date) >= 2 and dayofweek(date) <= 6
@svpino
svpino / last_monday.sql
Created Dec 18, 2015
How to determine last Monday's date in BigQuery
View last_monday.sql
select date(date_add(current_date(), if(dayofweek(current_date()) = 1, -6, -(dayofweek(current_date()) - 2)), "DAY"))
@svpino
svpino / towersOfHanoi.java
Last active Oct 1, 2017
Programming challenge: towers of Hanoi
View towersOfHanoi.java
// Programming challenge: towers of Hanoi
// Original post: https://blog.svpino.com/2015/06/07/programming-challenge-towers-of-hanoi
public class Main {
private static int NUMBER_OF_DISKS = 3;
public static void towersOfHanoi(int n, String rod1, String rod2, String rod3) {
if (n == 1) {
System.out.println("* Move disk from " + rod1 + " to " + rod3);
}
@svpino
svpino / pipeline_example.py
Created May 18, 2015
Google App Engine Pipeline API Example
View pipeline_example.py
# This pipeline sums up a bunch of values. That simple.
class SumPipeline(pipeline.Pipeline):
def run(self, *values):
return sum(values)
# This pipeline takes care of computing the score of one specific player
class PlayerScorePipeline(pipeline.Pipeline):
def run(self, player, level):
# Let's call our remote REST API to return the score
# of this player on the supplied level.
@svpino
svpino / PositionOfTheElement.java
Last active Aug 29, 2015
Programming challenge: the position of the element
View PositionOfTheElement.java
// Programming challenge: the position of the element
// Original post: https://blog.svpino.com/2015/05/24/programming-challenge-the-position-of-the-element
public class Main {
private static int[] array = { 1, 3, 5, 6 };
// Solution using a sequential search - O(n)
private static int sequential(int target) {
if (target < array[0]) {
return 0;
@svpino
svpino / MergingOverlappingIntervals.java
Last active Aug 29, 2015
Programming challenge: Merging overlapping intervals
View MergingOverlappingIntervals.java
import java.util.Arrays;
import java.util.Comparator;
// Programming challenge: Merging overlapping intervals
// Original post: https://blog.svpino.com/2015/05/17/programming-challenge-merging-overlapping-intervals
public class MergingOverlappingIntervals {
private static Integer[][] intervals = {
{1, 3},
{2, 6},
@svpino
svpino / Problem5.java
Created May 12, 2015
Problem 5 in "Five programming problems every Software Engineer should be able to solve in less than 1 hour"
View Problem5.java
import java.util.ArrayList;
// Solution to Problem 5 in "Five programming problems every Software Engineer should be able to solve in less than 1 hour"
// Original post: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
public class Main {
private static int TARGET_SUM = 100;
private static int[] VALUES = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
static ArrayList add(int digit, String sign, ArrayList branches) {
@svpino
svpino / Problem4.java
Created May 12, 2015
Problem 4 in "Five programming problems every Software Engineer should be able to solve in less than 1 hour"
View Problem4.java
import java.util.Arrays;
import java.util.Comparator;
// Solution to Problem 4 posted in "Five programming problems every Software Engineer should be able to solve in less than 1 hour"
// Original post: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
public class Main {
private static Integer[] VALUES = { 5, 2, 1, 9, 50, 56 };
public static void main(String[] args) {
@svpino
svpino / RotatingMatrix90DegreesInPlace.java
Last active Jun 8, 2018
Programming challenge: rotating a matrix 90 degrees in place
View RotatingMatrix90DegreesInPlace.java
// Programming challenge: rotating a matrix 90 degrees in place
// Original post: https://blog.svpino.com/2015/05/10/programming-challenge-rotating-a-matrix-90-degrees-in-place
public class RotatingMatrix90DegreesInPlace {
private static int[][] matrix = {
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 },
{ 13, 14, 15, 16 }
You can’t perform that action at this time.