Skip to content

Instantly share code, notes, and snippets.

View joncasdam's full-sized avatar

Jonatas CD joncasdam

View GitHub Profile
@joncasdam
joncasdam / python2_7_8_alongside_python2_6_on_CentOS
Last active August 29, 2015 14:05
Installing Python 2.7.8 on CentOS 6.x where Python 2.6.x is the current version
# Python 2.7.8 alongside 2.6 in CentOS
# based on Juliano Resende's tutorial at http://www.gorobei.net/instalando-o-python-2-7-8-no-centos-6-x/
# Make sure that your user is on sudoers and wheel group
$ usermod -G wheel usuario
# Some installing before going to python it self
$ yum update
$ yum install gcc44 gcc44-c++ gcc44-gfortran
$ yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
@joncasdam
joncasdam / floydwarshall.py
Created September 15, 2015 13:51
simple python implemetation of Floyd-Warshall alghorithm
def floydwarshall(graph):
# simple python implemetation of Floyd-Warshall alghorithm
# https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm#Path_reconstruction
# source: https://jlmedina123.wordpress.com/2014/05/17/floyd-warshall-algorithm-in-python/
# author: J. Luis Medina
dist = {}
pred = {}
for u in graph:
dist[u] = {}
pred[u] = {}
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
if conversion_type == 'csv_to_excel':
input_file = pd.read_csv(input_file)
input_file.to_excel(output_file)
elif conversion_type == 'excel_to_csv';
input_file = pd.read_excel(input_file)
import requests
import json
api_url = 'https://www.googleapis.com/urlshortener/v1/url'
api_key = '' # find here how to get yours https://developers.google.com/url-shortener/v1/getting_started#APIKey
url = '{0}?key={1}'.format(api_url, api_key)
headers = {'content-type': 'application/json'}
params = json.dumps({'longUrl': 'http://www.google.com'})
@joncasdam
joncasdam / deals_draft.json
Last active August 21, 2017 19:43 — forked from tmcls/deals_draft.json
Deals Json
[
{
"slug":"zalando",
"title":"Zalando",
"subtitle":"Shop online",
"visibility":"publishable",
"order": 2,
"has_highlighted_deal": true,
"is_published":true,
"logo_image":"https://www.dropbox.com/s/9005bsjr493xid5/100-crop-c0-5__0-5-200x200-70.jpg?dl=1",
@joncasdam
joncasdam / Alamofire.request.error.handling.swift
Created January 26, 2021 13:32 — forked from perlguy99/Alamofire.request.error.handling.swift
Alamofire Request Error Handling - From their documentation
Alamofire.request(urlString).responseJSON { response in
guard case let .failure(error) = response.result else { return }
if let error = error as? AFError {
switch error {
case .invalidURL(let url):
print("Invalid URL: \(url) - \(error.localizedDescription)")
case .parameterEncodingFailed(let reason):
print("Parameter encoding failed: \(error.localizedDescription)")
print("Failure Reason: \(reason)")