Skip to content

Instantly share code, notes, and snippets.

View opethe1st's full-sized avatar
🕶️
.

Ope opethe1st

🕶️
.
View GitHub Profile
@opethe1st
opethe1st / makehub
Created April 11, 2014 16:29
Arduino Powered Burglar Alarm
# Title
Arduino Powered Burglar Alarm
# Picture
media: http://www.deviantsart.com/3099afr.jpg
# Objective
Nigeria is a very hot place. Temperature averages 30 degree Celsius and even at Night the temperature is hot. The aim of this project is to regulate temperature by turning on the fan whenever the temperature reaches a certain level and turn it off whenever the temperature drops. This helps to conserve energy and also to improve comfort for the owner.
# Duration
40min
# Age Group
all
@opethe1st
opethe1st / gist:10490989
Created April 11, 2014 18:39
Arduino based PIR Motion sensor
// Uses a PIR sensor to detect movement, buzzes a buzzer
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
int pinSpeaker = 10; //Set up a speaker on a PWM pin (digital 9, 10, or 11)
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
@opethe1st
opethe1st / makehub
Last active August 29, 2015 14:17
Smart Farm
# Title
Smart Farm
# Picture
media: http://www.deviantsart.com/38fdru4.jpg
# Objective
A lot of people don't have the time or resources to grow their own food even though they would like to.
The goal of this project is to help ordinary people take care of their farms. It automatically waters the plants when it detects that the soil moisture level has gone below a certain treshold.
# Duration
2 hours
# Age Group
@opethe1st
opethe1st / lastword.py
Created April 11, 2017 11:27
lastword function
def lastWord(word):
if len(word)==1:
return word
lastletter = word[-1]
restOfWord = lastWord(word[:-1])
if ord(lastletter)>=ord(restOfWord[0]):
return lastletter+restOfWord
else:
return restOfWord+lastletter
def flip(s):
res = []
for l in s:
if l=='+':
res.append('-')
else:
res.append('+')
return "".join(res)
def countFlips(s,k):
def flip(s):
res = []
for l in s:
if l=='+':
res.append('-')
else:
res.append('+')
return "".join(res)
def flip(s):
"""changes all _ in s to + and all + in s to _"""
res = []
for l in s:
if l=='+':
res.append('-')
else:
res.append('+')
return "".join(res)
@opethe1st
opethe1st / EnumerateSets.cpp
Created June 25, 2017 13:07
Enumerate all possible subsets of a set.
#include <iostream>
#include <vector>
using namespace std;
void enumerate(vector<int> arr){
for(int current_set = 0; current_set < (1<<(arr.size()-1)); current_set++){
for(int j=0; j<arr.size(); j++){ // j is the position in arr.
if (current_set & (1<<j)){ // if the bit is set in this set, then arr[j] is in the set
cout<<arr[j]<<',';
}
}
solution = []
def possibleCombinations(N, items):
if N < 0:
return
if N == 0:
print solution
else:
for k in items:
import re
import os
import sys
for directory in sys.path:
for directory, subDirectories, files in os.walk(directory):
for file in files:
if file.endswith('.py'):
filepath = os.path.join(directory, file).replace('/', '.')