Skip to content

Instantly share code, notes, and snippets.

View 0ex-d's full-sized avatar
💭
Engr. management

Precious 0ex-d

💭
Engr. management
  • Irgendwo, Irgendwohin (100% remote)
View GitHub Profile
@0ex-d
0ex-d / simpleserver.py
Last active August 1, 2020 20:27
Python middle-ware to watch for changes in directory (Using watchdog)
"""
Implements the basic http server and also
watch for directory changes,
requires pip install watchdog"""
import sys
import time
import logging
import http.server
import socketserver
@0ex-d
0ex-d / gasoptimize.py
Created June 7, 2016 06:13
A quick implementation of algorithms in gas stations
class Gas():
"""Gas lookup optimization"""
def __init__(self, gas, cost):
self.gas = gas
self.cost = cost
def canCompleteCircuit(self):
n = len(self.gas)
start = 0
total = 0
tank = 0
@0ex-d
0ex-d / import-joomla.php
Created June 7, 2016 06:21
Import Joomla to your MVC for some reasons
<?php
/*
* Swiftly: Import Joomla for some reasons
* N.B: Our 'JPATH_BASE' is not in same dir
* June 05, 2016
*/
if (!defined('_JEXEC')) {
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)) );
@0ex-d
0ex-d / compare-array-sequence.py
Created October 14, 2016 20:39
Given an array of ints, return True if the sequence.. 1, 3, 4 .. appears in the array somewhere
'''
Python code to compare arrays(lists) sequence
@author: Precious Kindo
Sample space: [1,3,4]
input: A is sample space
input: B is list to be compared against
Output: Bool
'''
def checkInt(A, B):
return bool(A in B) # return True or False
@0ex-d
0ex-d / gdax-py-wrapper.py
Created November 12, 2016 08:55
GDAX Python Wrapper
import GDAX, time
from geminipy import Geminipy
#set trade size in BTC
trade_size = '0.0001'
trade_threshold = 0
improvement_amount = 0.1
live_toggle = True
place_orders = True
@0ex-d
0ex-d / auth_controller.rb
Created February 2, 2017 01:16
Simple Login Logic in Rails
class AuthController < ApplicationController
before_action :is_user_authenticated
def is_user_authenticated
unless current_user
flash[:alert] = "Please log in"
redirect_to new_user_session_path
end
@0ex-d
0ex-d / ubuntu14.04-command-line-install-android-sdk
Created February 22, 2017 17:58 — forked from wenzhixin/ubuntu14.04-command-line-install-android-sdk
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@0ex-d
0ex-d / meta-og-tags.html
Last active March 16, 2017 22:08
Quickly Setup Open Graph(og) tags for social media optimization
<link rel="canonical" href="{page.url}" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="{page.title}" />
<meta property="og:url" content="{page.url}" />
<meta property="og:site_name" content="{site.name}" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="{page.title}" />
<script type='application/ld+json'>
{
@0ex-d
0ex-d / match_random_target.py
Created January 22, 2020 06:50
Generate Random String until target is matched
# Python program to generate and match
# the string from all random strings
# of same length
# Importing string, random
# and time modules
import string
import random
import time
# Method 1
def create_obj():
id = ''.join(random.choices(string.digits, k=8))
try:
MyModel.objects.save(id=id)
except IntegrityError:
create_obj()
# Method 2
def create_unique_id():