Skip to content

Instantly share code, notes, and snippets.

View lukaszsagol's full-sized avatar
👁️‍🗨️

Łukasz Sągol lukaszsagol

👁️‍🗨️
View GitHub Profile
@lukaszsagol
lukaszsagol / helloWorld-wrapped.f.ts
Created July 19, 2021 09:54
How to capture TypeScript Firebase functions errors in Sentry
exports = module.exports = functions.https.onCall(
httpsOnCallWrapper('helloWorld', helloWorldHandler)
)
@lukaszsagol
lukaszsagol / helloWorld.f.ts
Created July 19, 2021 09:52
How to capture TypeScript Firebase functions errors in Sentry
import * as functions from 'firebase-functions'
const helloWorldHandler = async () => {
// Do exciting function things here
return { done: true }
}
exports = module.exports = functions.https.onCall(helloWorldHandler)
@lukaszsagol
lukaszsagol / sentryWrapper.ts
Last active July 21, 2021 15:30
How to capture TypeScript Firebase functions errors in Sentry
import * as Sentry from '@sentry/node'
import { https } from 'firebase-functions'
Sentry.init(
// Add your Sentry configuration here or import it
)
export const httpsOnCallWrapper = (
// We pass an identifying ‘name’ as a string
version: '2'
services:
web:
build:
context: ./
dockerfile: Dockerfile
volumes:
- ./:/code
ports:
- 4000:4000
# What we want to use as a base of our container.
# We all know Ubuntu, so why not.
FROM ubuntu:14.04
# Some locale setting business, better to have it than not.
ENV DEBIAN_FRONTEND=noninteractive
RUN locale-gen en_GB.UTF-8
ENV LANG en_GB.UTF-8
ENV LANGUAGE en_GB:en
ENV LC_ALL en_GB.UTF-8
def create
create! do |success, failure|
success.html { flash[:notice] = nil; redirect_to whatever }
end
end
@lukaszsagol
lukaszsagol / osx-ruby-install.sh
Created October 3, 2013 23:46
Installing Ruby (example for 2.0.0-p247) on OSX with rbenv (along with openssl and readline) using homebrew
brew update
# skip to line 14 if you have rbenv
# and ruby-build installed
brew install rbenv ruby-build
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
fi
@lukaszsagol
lukaszsagol / lambdas.rb
Created September 24, 2013 11:55
Lambdas in case expressions
def is(method_sym)
->(subject) { subject.send method_sym }
end
case user
when is(:admin) then puts 'Woohoo! Admin'
when is(:editor) then puts 'Editor'
else puts 'User'
end
@lukaszsagol
lukaszsagol / period.js
Last active December 19, 2015 22:28 — forked from piecioshka/getPeriod.js
Additional support for parsing multiple periods in one string and adding them up (eg. "10h 30m")
function getPeriods(periods) {
var splittedPeriods = periods.match(/\d+(ms|s|m|h|d|o|y)/g);
var sum = 0;
splittedPeriods.forEach(function(period) {
sum += getPeriod(period);
});
return sum;
};
@lukaszsagol
lukaszsagol / gist:973516
Created May 15, 2011 20:43
typhoeus example
hydra = Typhoeus::Hydra.new :max_concurrency => 5
urls = %w(http://www.google.com/ http://engadget.com/
http://rubyonrails.org/ http://railscasts.com/)
responses = []
urls.each do |url|
req = Typhoeus::Request.new url
req.on_complete do |resp|
if resp.success?
responses << resp.body