Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Peter Edache freewayz

🏠
Working from home
  • Remote
  • Internet
Block or report user

Report or block freewayz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View number_to_string.js
// number to string, pluginized from http://stackoverflow.com/questions/5529934/javascript-numbers-to-words
window.num2str = function (num) {
return window.num2str.convert(num);
}
window.num2str.ones=['','one','two','three','four','five','six','seven','eight','nine'];
window.num2str.tens=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'];
window.num2str.teens=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'];
@freewayz
freewayz / admin.py
Created Nov 12, 2017 — forked from mattlong/admin.py
Add a custom admin page for a model and link to it from the detail page
View admin.py
from functools import update_wrapper
from django.contrib import admin
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from myapp.models import Widget
from myapp.forms import ManageWidgetForm
@freewayz
freewayz / annotations.swift
Created Sep 9, 2017
My first two hours on swift
View annotations.swift
var shouldStoreDouble: Double = 200.0 // we restrict this by adding an annotation
print("Double annotation ", shouldStoreDouble);
// let see when we say our computer should create
// a memory space for string but we try to store an integer
var onlyStringPlease: String = "John"
print("String annotation ", onlyStringPlease)
View GWT Compiler Options
Source : https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging
java -cp gwt-dev.jar com.google.gwt.dev.Compiler
Missing required argument 'module[s]'
Google Web Toolkit 2.3.0
Compiler [-logLevel level] [-workDir dir] [-gen dir] [-style style] [-ea] [-XdisableClassMetadata] [-XdisableCastChecking] [-validateOnly] [-draftCompile] [-optimize level] [-compileReport] [-strict] [-localWorkers count] [-war dir] [-deploy dir] [-extra dir] module[s]
where
-logLevel The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL
-workDir The compiler's working directory for internal use (must be writeable; defaults to a system temp dir)
@freewayz
freewayz / flatten_array.py
Created Feb 12, 2017
Python implementation of flatten an array
View flatten_array.py
def flatten_array(arr):
output = []
for val in arr:
if type(val) == list: # is the current value we are looking at is also a list
output.extend(flatten_array(val)) # then recursive call itself to start from
# the beginning and use python list extend
else:
output.append(val) # ok this is not a list just append to the bottom
return output
@freewayz
freewayz / capitalize-obj.js
Created Oct 11, 2016
Iterating over array of object and capitailizing the first leter
View capitalize-obj.js
var myResponse = {"start_date":["A valid integer is required."],
"end_date":["A valid integer is required."], "commite":["Require commite."]}
//iterate over the serializer error message
for (var prop in myResponse) {
var errorValue = myResponse[prop];
//test if the current prop has an _ in it string value
var _pattern = /_/;
if (_pattern.test(prop)) {
@freewayz
freewayz / capitalize-obj.js
Created Oct 11, 2016
Iterating over array of object and capitailizing the first leter
View capitalize-obj.js
var myResponse = {"start_date":["A valid integer is required."],
"end_date":["A valid integer is required."], "commite":["Require commite."]}
//iterate over the serializer error message
for (var prop in myResponse) {
var errorValue = myResponse[prop];
//test if the current prop has an _ in it string value
var _pattern = /_/;
if (_pattern.test(prop)) {
@freewayz
freewayz / frontendDevlopmentBookmarks.md
Created Oct 7, 2016 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
View frontendDevlopmentBookmarks.md
@freewayz
freewayz / aws-boto-s3-download-directory.py
Created Oct 6, 2016
Download files and folder from amazon s3 using boto and pytho local system
View aws-boto-s3-download-directory.py
#!/usr/bin/env python
import boto
import sys, os
from boto.s3.key import Key
from boto.exception import S3ResponseError
DOWNLOAD_LOCATION_PATH = os.path.expanduser("~") + "/s3-backup/"
if not os.path.exists(DOWNLOAD_LOCATION_PATH):
@freewayz
freewayz / django_model_deletable.py
Created Sep 27, 2016
Django check if model has related object before Deleting the model
View django_model_deletable.py
#After looking for a way to check if a model instance can be deleted in django ,
#i came across many sample, but was not working as expected. Hope this solution can help.
#Let start by creating an Abstract model class which can be inherited by other model
class ModelIsDeletable(models.Model):
name = models.CharField(max_length=200, blank=True, null=True, unique=True)
description = models.CharField(max_length=200, blank=True, null=True)
date_modified = models.DateTimeField(auto_now_add=True)
You can’t perform that action at this time.