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
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 |
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 | |
/* | |
* 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__)) ); |
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 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 |
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
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 | |
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
''' | |
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 |
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
# 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 |
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
# 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 |
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
# 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(): |
OlderNewer