Skip to content

Instantly share code, notes, and snippets.

View ferostabio's full-sized avatar

Federico Erostarbe ferostabio

View GitHub Profile
import express, { Request, Response } from "express";
import axios from "axios";
import { createClient } from "redis";
const FIFTEEN_MINUTES_IN_MILLISECONDS = 15 * 60 * 1000;
const THREE_DAYS_IN_SECONDS = 3 * 24 * 60 * 60;
const PORT = Number(process.env.PORT) || 3000;
const REDIS_URL: string = process.env.REDIS_URL ?? "";
import express from "express";
import axios from "axios";
import { createClient } from "redis";
import { promisify } from "util";
const app = express();
const PORT = process.env.PORT || 3000;
const REDIS_URL = process.env.REDIS_URL; // Replace with actual one
export const URLS = {
@ferostabio
ferostabio / referrals.js
Last active August 1, 2023 15:13
referrals.js
const axios = require('axios');
const API_KEY = process.env.REFERRAL_API_KEY;
const CAMPAIGN_ID = process.env.REFERRAL_CAMPAIGN_ID;
const REQUIREMENT_ID = process.env.REFERRAL_REQUIREMENT_ID;
const BASE_URL = process.env.REFERRAL_BASE_URL;
const SYNC_USER_PATH = '/users';
const UPDATE_TRACKED_BALANCE_PATH = (userId) =>
`/users/${userId}/campaign/${CAMPAIGN_ID}/tracked/balance`;
@ferostabio
ferostabio / cthulhu.rb
Last active December 13, 2015 19:09
Script that prints 50 more used terms in a given Lovecraft story passed as argument
class CthulhuBag
def initialize
@h = Hash.new{ 0 }
end
def <<(o)
@h[o] += 1
end
def [](o)
@h[o]
end
@ferostabio
ferostabio / pijama.rb
Last active December 12, 2015 07:49
Script that uses nokogiri and data-mapper to fetch and store data from my posts in PijamaSurf
# encoding: utf-8
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'data_mapper'
require 'dm-sqlite-adapter'
require 'date'
require 'set'
require 'json'
@ferostabio
ferostabio / quietlog
Created September 26, 2012 21:43
NSLog alternative that doesn't logs time and process
void QuietLog (NSString *format, ...) {
va_list argList;
va_start (argList, format);
NSString *string;
string = [[NSString alloc] initWithFormat: format
arguments: argList];
va_end (argList);
printf ("%s\n", [string UTF8String]);
}
@ferostabio
ferostabio / gist:1431192
Created December 4, 2011 20:29
Avoid iCloud syncing
- (BOOL) addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
@ferostabio
ferostabio / NSString+Contains.m
Created July 10, 2011 03:07
NSString category to test whether an NSString contains another one
#import "NSString+Contains.h"
@implementation NSString (Contans)
- (BOOL) containsString: (NSString*) substring
{
NSRange range = [self rangeOfString : substring];
BOOL found = ( range.location != NSNotFound );
return found;
}