This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include Faker in your project (https://github.com/fzaninotto/Faker#installation) | |
use Faker\Factory as Faker; | |
$faker = Faker::create(); | |
$regex = "/(\+?254|0){1}[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}/"; | |
$samplePhoneNumber = $faker->regexify($regex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# KE | |
SAFARICOM: "/(\+?254|0|^){1}[-. ]?[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}\z/" | |
AIRTEL: "/(\+254|0|^){1}[-. ]?[7]{1}([3]{1}[0-9]{1}|[8]{1}[5-9])[0-9]{6}\z/" | |
# TZ | |
TIGO: "/(\+?255|0|^){1}[-. ]?([7]{1}[1]{1}[2-9]{1}|[6]{1}[57]{1}[2-9]{1})[0-9]{6}\z/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from logging import FileHandler | |
from logging import Formatter | |
LOG_FORMAT = ( | |
"%(asctime)s [%(levelname)s]: %(message)s in %(pathname)s:%(lineno)d") | |
LOG_LEVEL = logging.INFO | |
# messaging logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from dateutil import parser as date_parser | |
from dateutil import tz | |
def convert_timestamp_timezone(timestamp, from_tz="UTC", to_tz="UTC"): | |
""" | |
function to convert a string timestamp between timezones | |
@timestamp - A string timestamp (dateutil.parser will be used to parse) | |
@from_tz - A string, the current timezone as a string. | |
@to_tz - A string, the timezone to convert the time to. | |
Refer to: http://goo.gl/hmPXML for a list of acceptable TZ strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// FoodTracker | |
// | |
// Created by Muya on 14/07/2015. | |
// Copyright © 2015 muya. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get first and last .gz | |
first_file=$(ls *gz|head -1) | |
last_file=$(ls *gz |tail -1) | |
echo "first file: "$first_file | |
echo "last file: "$last_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from peewee import * | |
import datetime | |
database = SqliteDatabase("/data/amazing_people.db", **{}) | |
class BaseModel(Model): | |
class Meta: | |
database = database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% highlight html %} | |
{% raw %}{% if post.excerpt %}{% endraw %} | |
{% raw %}{{ post.excerpt }}{% endraw %} | |
{% raw %}{% else %}{% endraw %} | |
{% raw %}{{ post.content | truncatewords:30 }}{% endraw %} | |
{% raw %}{% endif %}{% endraw %} | |
{% endhighlight %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
class MinifyOnSave(sublime_plugin.EventListener): | |
def on_post_save(self, view): | |
file_types_to_minify = ['js', 'css'] | |
filenameParts = view.file_name().split('.') | |
if filenameParts[len(filenameParts) - 1] in file_types_to_minify: | |
view.run_command('minify') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return array relational rules. | |
*/ | |
public function relations() | |
{ | |
// NOTE: you may need to adjust the relation name and the related | |
// class name for the relations automatically generated below. | |
return array( | |
'studentProfiles' => array(self::HAS_MANY, 'StudentProfiles', 'userID'), | |
'userGroupMappings' => array(self::HAS_MANY, 'UserGroupMappings', 'userID'), |
NewerOlder