Skip to content

Instantly share code, notes, and snippets.

View frojasg's full-sized avatar

Francisco Rojas frojasg

  • San Francisco, California
View GitHub Profile
@frojasg
frojasg / PriceSyncer.kt
Last active June 21, 2021 15:32
playing with coroutines
package frojasg.marketprices
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.ticker
import kotlinx.coroutines.flow.*
import java.time.Clock
import java.time.Instant
import java.lang.IllegalStateException
@frojasg
frojasg / active_merchant_square_api.rb
Last active June 22, 2017 21:20
ActiveMerchantSquare API
def purchase(money, card_nonce, options={})
 def authorize(money, card_nonce, options={})
 def capture(ignored_money, txn_id, ignored_options={})
 def refund(money, txn_id, options={})
 def void(txn_id, options={})
 def verify(card_nonce, options={})
 def store(card_nonce, options = {})
 def update(customer_id, card_id, options = {})
 def update_customer(customer_id, options = {})
 def unstore(card_id, options = {}, deprecated_options = {})
@frojasg
frojasg / active_merchant_square_demo.rb
Created June 22, 2017 21:10
ActiveMerchantSquare
require 'active_merchant_square'
# Get your login and password by going to: https://connect.squareup.com/apps
credentials = {
login: 'APPLICATION_ID',
password: 'APPLICATION_SECRET',
# How to get your location ID, see: https://docs.connect.squareup.com/articles/faq-lookup-my-location-id
location_id: 'LOCATION_ID',
}
https://www.dropbox.com/s/niswxlguq9saxxp/presentacionv1.pdf?dl=0
  install.packages(ggplot2)
  library(ggplot2)
  ggplot(AgeAnxietyNoOutliers, aes(x=Age, y=Anxiety)) + stat_function(fun=function(x) 3.533 + 0.001012*x,  geom="line", aes(colour="Model")) + geom_point()

You will see the following image: graph

@frojasg
frojasg / generator.scala
Created April 20, 2015 01:12
Class defined during the first week of the course reactive-002
trait Generator[+T] {
self =>
def generate: T
def map[S](f: T => S): Generator[S] = new Generator[S] {
def generate = f(self.generate)
}
def flatMap[S](f: T => Generator[S]): Generator[S] = new Generator[S] {
def generate = f(self.generate).generate
@frojasg
frojasg / keybase.md
Created October 18, 2014 15:36
keybase.md

Keybase proof

I hereby claim:

  • I am frojasg on github.
  • I am frojasg (https://keybase.io/frojasg) on keybase.
  • I have a public key whose fingerprint is 0C46 D7E1 11DC 9E24 1145 7C39 FE4E C7B9 FD0B FBD0

To claim this, I am signing this object:

@frojasg
frojasg / aaa.java
Last active August 29, 2015 14:01
problema 1234
mport java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int cases = Integer.parseInt(line);
@frojasg
frojasg / typhoeus-caching-with-web-mock
Created June 28, 2013 19:43
Try to use caching when we use WebMock library
diff --git a/Gemfile b/Gemfile
index b235c52..2cfee39 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,7 @@ group :development, :test do
gem "sinatra", "~> 1.3"
gem "json"
gem "faraday", "~> 0.8.4"
+ gem "webmock"
@frojasg
frojasg / Matrix.java
Created January 10, 2011 12:07
zig-zag
public class Matrix {
public static void main(String [] args){
int n = Integer.parseInt(args[0]);
int[][] A = new int[n][n];
int count = 0;
for(int i = 0; i< n; i++) {
for(int j = i, z=0; j>=0 && z <= i; j--, z++){
if(i%2==1) {
A[z][j]=count;