Skip to content

Instantly share code, notes, and snippets.

@IamSmith
IamSmith / FullExample.php
Created April 8, 2011 17:53
Fully working example
<?php
require_once("PHPExcel/PHPExcel.php");
$phpExcel = new PHPExcel();
$styleArray = array(
'font' => array(
'bold' => true,
)
);
@c0ldlimit
c0ldlimit / gist:5164171
Created March 14, 2013 19:00
#python #flask #pandas Using flask to return a csv response from a dataframe
import StringIO
from flask import Flask, Response
@app.route('/some_dataframe.csv')
def output_dataframe_csv():
output = StringIO.StringIO()
some_dataframe.to_csv(output)
@niksumeiko
niksumeiko / git.migrate
Last active May 31, 2024 21:18
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@hootlex
hootlex / laravellocal.md
Last active June 11, 2024 19:08
Run laravel project locally

##Windows users:

cmder will be refered as console

##Mac Os, Ubuntu and windows users continue here:

  • Create a database locally named homestead utf8_general_ci
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@jeremycg
jeremycg / twitterfollow.py
Created December 24, 2015 17:19
get list of twitter followers using python
from twython import Twython
import csv
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
followers = twitter.get_followers_list(screen_name = "yourusername", count = 200)
following = twitter.get_friends_ids(screen_name = "yourusername")
with open("twitter.csv", 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',')
writer.writerow(["name", "tweets", "following", "followers", "I'm following"])
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active June 13, 2024 14:23
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@dasdachs
dasdachs / csv_to_flask.py
Created July 24, 2016 13:14
Upload, read and save the content of a csv file to your model
#!/usr/bin/env python
from io import TextIOWrapper
import csv
from flask import Flask, request, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
# Create Flaskk app, config the db and load the db object
# http://flask-sqlalchemy.pocoo.org/2.1/quickstart/#a-minimal-application
@devdrops
devdrops / example.md
Last active March 25, 2024 15:09
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
@debashisbarman
debashisbarman / forwardport.sh
Created May 15, 2020 10:43 — forked from Bostonncity/forwardport.sh
Forward port 80 to 8080 on EC2 instance.
sudo iptables -t nat -L
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000