Skip to content

Instantly share code, notes, and snippets.

View genuinemoses's full-sized avatar
👨‍💻
Writing and breaking code for humanity, fun and profit!

Moses genuinemoses

👨‍💻
Writing and breaking code for humanity, fun and profit!
View GitHub Profile
@Nemolog
Nemolog / ByteZoneFtp.py
Created March 1, 2009 21:22
ftp command line
import ftplib
def command():
cmd = raw_input(login +"@" + host +">")
#upload
if cmd=="upload":
filename = raw_input("Insert file name:")
#Upload a binary file from your disk
ftp.storbinary('STOR '+filename, open(filename,'rb'))
print "file upload success!"
@ryanflorence
ryanflorence / static_server.js
Last active June 10, 2024 02:37
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@scturtle
scturtle / ftpserver.py
Created June 20, 2011 16:03
simple ftp server by python
#!/usr/bin/env python2
# coding: utf-8
import os,socket,threading,time
#import traceback
allow_delete = False
local_ip = socket.gethostbyname(socket.gethostname())
local_port = 8888
currdir=os.path.abspath('.')
#!/usr/bin/env python
# ____ __ _ __
# / __ \___ ________ _____/ /__________ (_) /______ _
# / /_/ / _ \/ ___/ _ \/ ___/ __/ ___/ __ \/ / //_/ __ `/
# / ____/ __/ / / __(__ ) /_/ / / /_/ / / ,< / /_/ /
#/_/ \___/_/ \___/____/\__/_/ \____/_/_/|_|\__,_/
#
# Yet another threaded, multi-part file downloader
#
# Copyright (c) Alexandre Gauthier 2010-2011
@gferreira
gferreira / upload-file-to-server.py
Created July 12, 2011 00:05
upload file to server via ftp
import os
from ftplib import FTP
def connectToServer(url, login, password, folder, verbose=False):
# create FTP connection
ftp = FTP(url, login, password)
if verbose == True:
print "%s" % ftp.getwelcome()
# move to folder
@rocarvaj
rocarvaj / .vimrc
Created April 27, 2012 21:28
Minimal .vimrc for C/C++ developers
" VIM Configuration File
" Description: Optimized for C/C++ development, but useful also for other things.
" Author: Gerhard Gappmeier
"
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
" disable vi compatibility (emulation of old bugs)
@jboner
jboner / latency.txt
Last active June 25, 2024 12:58
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@wenshn902
wenshn902 / ftp2.py
Created October 28, 2012 13:54
ftp use pyrhon
# -*- coding: cp936 -*-
__author__ = 'wenshn902'
import string
from ftplib import FTP
bufsize=1024
def Get(filename):
command='RETR '+filename
ftp.retrbinary(command,open(filename,'wb').write,bufsize)
print 'download successfully'
def Put(filename):
@ivan-krukov
ivan-krukov / ftp-download.py
Created June 6, 2013 03:50
Complete download file over FTP example. Complete with write-report closure in python3 style, writing stdout to same line and nice verbosity handling
#!/usr/bin/env python3
from ftplib import FTP
def ftp_download(server,remote_path,local_path,username="anonymous",password="",verbose=True):
#new ft object
ftp = FTP(server)
if verbose: print("Connected to %s"%server)
#notice that default login is "anonymous" with no password. works on most public servers