Skip to content

Instantly share code, notes, and snippets.

View freewayz's full-sized avatar
🏠
Working from home

Peter Edache freewayz

🏠
Working from home
View GitHub Profile
@freewayz
freewayz / boto-s3-upload-directory.py
Created August 12, 2016 10:35
How to use python and amazon boto to upload the Amazon s3
DIR_TO_UPLOAD = 'project-dist'
def upload_percent_cb(complete, total):
sys.stdout.write('-')
sys.stdout.flush()
def remove_root_dir_from_path(c):
s = c.split('/')
s.remove(DIR_TO_UPLOAD)
@freewayz
freewayz / RandomURLKeyGenerator.java
Created July 21, 2016 11:03
How to generate a secure random safe URL in Java, using apache libary
import org.apache.commons.codec.binary.Base64;
import java.security.SecureRandom;
/**
* Created by pitaside on 7/12/2015.
*/
public class RandomURLKeyGenerator {
public static String generateURLKey(int length) {
var myObjArray = [
{
name: 'peter',
age: 25
},
{
name: 'john',
age: 15
@freewayz
freewayz / Hello.js
Last active January 26, 2016 12:02
React ES6 component creation
class App extends React.Component {
static propTypes = {
params: PropTypes.object.isRequired,
};
state = {
....
};
componentWillMount() {
var InputComponent = React.createClass({
propTypes: {
type: React.PropTypes.string,
placeholder: React.PropTypes.string,
id: React.PropTypes.string,
classStyle: React.PropTypes.string,
defaultVal: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
@freewayz
freewayz / json-object-js-object.js
Created January 4, 2016 18:51
Passing json to object in javascript object
/*
Please feel free to comment and any advice
* Created by peter
*/
var Person = {}
// an empty person object
//sample json object, can also be from a server
var sampleJson = {'name': 'Peter', 'age': "20"};
@freewayz
freewayz / simple-oop.js
Created January 4, 2016 18:43
Simple OOP concept in javascript
//how i started understanding my javascript oop concept based on ES5
//welcome comment and and
var Bank = function(name,acct_bal){
this.name = name; this.acct_bal = acct_bal;
}
Bank.prototype.deposit = function(amount){
this.acct_bal += amount;
console.log("Deposited =$" + amount + "\nYour balance is $" + this.acct_bal);
//simple work arroud on getting a property type using a matcher from an array
//welcome any comment and modification / enhacnement
var myArray = [{"name" : "pitaside", "id" : 1}, {"name":"github", "id" : 3}]
filterArrayByType: function (arrayToMatch, fieldType, matcher) {
if(! arrayToMatch instanceof Array){throw ("Not an Array")}
var filterTypeToReturn = arrayToMatch.filter((items) => {
var temp;
if (items[String(fieldType)] === matcher) {
temp = items[String(fieldType)]