Skip to content

Instantly share code, notes, and snippets.

Working from home

KhoPhi seanmavley

Working from home
View GitHub Profile
seanmavley /
Last active May 23, 2016
Allow user submit form once per day
# The problem:
# A user has to be able to submit a form only once per day
# The solution - my approach
# A hidden form (connected to a kinda Control Model) is embedded in the normal form the user submits.
# Hidden form when submitted, triggers a save on a model ForeignKey'ed
# to the request.user
# Upon re-rendering form, Control Model is checked. If an object exist relating to user in context,
# no form shows in template
View phpStrtime in javascript.js
// first day of the month
var firstDayThisMonth = moment(firstDayThisMonth).startOf('month').toDate();
Go back and forth using the subtract() and add() with the endOf() and startOf():
// last day of previous month
var yesterMonthLastDay = moment(yesterMonthLastDay).subtract(1,'months').endOf('month').toDate();
seanmavley / network_available.js
Created Mar 29, 2016
check network connectivit
View network_available.js
// Register listeners
window.addEventListener("offline", function(){
$("#message").html('WARNING: Internet connection has been lost.').show();
window.addEventListener("online", function(){
seanmavley / forms for meteor.js
Created Mar 23, 2016
gather all form elements
View forms for meteor.js
(function() {
var form = document.getElementById('form_837299');
form.addEventListener('submit', function(event) {
// Prevent normal form submit
# backup using
# Usage:
# ./backup-script nameOfFolder
# e.g
# ~$ ./backup-script Folder SecondFolder
echo "Starting backup"
for i
seanmavley /
Created Jan 23, 2016 — forked from sgnn7/
Mongodb 3.2 on Ubuntu 15.10
echo '[Unit]
Description=High-performance, schema-free document-oriented database
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
View primary.html
{% load pages_tags i18n mezzanine_tags %}
{% if page_branch_in_menu %}
{% if branch_level == 0 %}
<a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
<li> <a class="modal-trigger" href="#searchbox"><i class="material-icons">search</i></a></li>
{% if user.is_authenticated %}
<li> <a href="{% url 'add_project' %}"><i class="material-icons">add</i></a></li>
{% endif %}
seanmavley / gist:92a851b7ed6a1f36945a
Created Oct 11, 2015
Can't Sync Android Source Code on Ubuntu. Always getting: 'Failed to connect to port 443: Network is unreachable'. Enter the following commands, and profit
View gist:92a851b7ed6a1f36945a
sudo ip -6 route del default
net.ipv6.conf.default.accept_ra_defrtr = 0