Skip to content

Instantly share code, notes, and snippets.

View vsouza's full-sized avatar
:octocat:
Coding time

Vinicius Souza vsouza

:octocat:
Coding time
View GitHub Profile
<?hh
async function stream_check(resource $stream, string $mode, int $usec): Awaitable<void>
{
$r = $w = $e = null;
do {
if ($mode == "r") {
$r = Vector{$stream};
}
@DougFischer
DougFischer / GiveMyModalsOrientationsBack
Created October 9, 2013 05:09
On iOS6+, the orientation of modal view controllers is handled by the view controller who present them. If you're using UITabBarController, it can be a little confusing, since you need to add presenting view controller some code to handle the modal controller's visibility. This code snippet shows how to have all UIViewControllers orientations (p…
#pragma mark -
#pragma mark UIApplication Delegate
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)pWindow {
UITabBarController *tabCtrl = (UITabBarController *)self.window.rootViewController;
//Check if there's a modal view controller on screen (dismissing modal view controllers are ignored)
if (tabCtrl.selectedViewController.presentedViewController && !tabCtrl.selectedViewController.presentedViewController.isBeingDismissed) {
return tabCtrl.selectedViewController.presentedViewController.supportedInterfaceOrientations;
}
import pandas as pd
data = {'a': [1, 3, 4, 4], 'b': [1, 3, 2, 3]}
df = pd.DataFrame(data=data)
df.to_csv("data/old_data.csv")
data2 = {'a': [1, 3, 5, 4], 'b': [1, 3, 2, 3]}
df2 = pd.DataFrame(data=data2)
df2.to_csv("data/new_data.csv")
@vsouza
vsouza / request.swift
Last active May 31, 2016 13:21
Simple HTTP request. Swift backend implementation
import HTTP
import File
import HTTPSClient
import JSON
var url: String?
do {
let client = try! Client(uri: "https://api.github.com:443")
var response = try client.get("/repos/vsouza/awesome-ios/git/trees/HEAD")
let buffer = try response.body.becomeBuffer()
import os
import httplib
import tornado.web
class ErrorHandler(tornado.web.RequestHandler):
"""Generates an error response with status_code for all requests."""
def __init__(self, application, request, status_code):
tornado.web.RequestHandler.__init__(self, application, request)
self.set_status(status_code)
@KronicDeth
KronicDeth / elixirconf-2017-recap.md
Created September 22, 2017 21:18
Recap of all talks at ElixirConf 2017

Elixir Native UI - Boyd Multerer https://www.youtube.com/watch?v=77FW-jrCyCs

Thinking In Ecto - Darin Wilson https://www.youtube.com/watch?v=YQxopjai0CU

  1. Repository pattern https://youtu.be/YQxopjai0CU?t=2m12s
  2. Explicitness https://youtu.be/YQxopjai0CU?t=5m29s
@lucasrcosta
lucasrcosta / tornado_handler_thread_decorator.py
Last active February 20, 2019 08:51
Tornado Handler Thread Decorator
from concurrent.futures import ThreadPoolExecutor
from datetime import timedelta
from tornado import gen
from tornado.concurrent import run_on_executor
THREADPOOL_MAX_WORKERS = 10
THREADPOOL_TIMEOUT_SECS = 30
def onthread(function):
@oddskool
oddskool / parse_aws_s3_billing.py
Created September 10, 2013 07:00
Simplistic script to parse the detailed AWS billing CSV file. Script displays cost of S3 operations broken down per region, bucket and usage type (either storage or network). It also sums up the amount of storage used per bucket. Output is filtered wrt to costs < 1$. See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html
# -*- coding:utf-8 -*-
'''
Simplistic script to parse the detailed AWS billing CSV file.
Script displays cost of S3 operations broken down per region, bucket and usage
type (either storage or network). It also sums up the amount of storage used per bucket.
Output is filtered wrt to costs < 1$.
See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html for
how to set up programmatic access to your billing.
@ijt
ijt / http_get.go
Last active August 23, 2021 12:37
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)