Skip to content

Instantly share code, notes, and snippets.

Avatar

Mardix mardix

View GitHub Profile
@mardix
mardix / autocomplete.py
Created September 16, 2020 01:13 — forked from jedp/autocomplete.py
autocomplete.py - redis autocompleter
View autocomplete.py
"""
A redis autocomplete example for multi-word phrases.
Based on:
Ruby original: http://gist.github.com/574044
Python original: https://gist.github.com/577852
See options below for usage
Requires http://github.com/andymccurdy/redis-py/
View gist:63b1b6ee8afd74695a58c96001a9b765
Install Dokku
# must have dokku as username
git remote add dokku dokku@example.com:flask-example
# Edit Procfile
...
# Push
View gist:4dafb453e17d9a8efb064cf622aa7308
Remove culprit server
ssh-keygen -R remote-server-name-here
@mardix
mardix / gist:00fa3606f56fa9e5ab87b1f4d30e4bc6
Created August 25, 2019 19:12
To release pypi package
View gist:00fa3606f56fa9e5ab87b1f4d30e4bc6
# To release pypi package
alias pypi-publish='python setup.py register -r pypi && python -m twine upload dist/*'
@mardix
mardix / relift-example-stars-wars-simple.html
Last active April 21, 2019 00:57
relift-example-stars-wars-simple.html
View relift-example-stars-wars-simple.html
<div>
<div class="row">
<div class="column" id="starWarsWidget">
<div class="center">
<span r-if="(this.loadingStatus === 'pending')">
<div class="spinner">Loading...</div>
</span>
<h4 r-else>Welcome to Star Wars</h4>
</div>
<div>
@mardix
mardix / relift-example-todo.html
Last active April 19, 2019 20:31
relift-example-todo.html
View relift-example-todo.html
<div>
<div class="column" id="todoAppWidget" style="display:none">
<div class="center">
<div>Enter your item</div>
<input type="text" id="todo-input" />
<button @click="add">Save</button>
</div>
<div>
<ul>
<li r-for="item,i in this.todos">
@mardix
mardix / relift-example-counter.html
Last active April 19, 2019 20:02
relift-example-counter.html
View relift-example-counter.html
<div>
<div class="column center" id="counterWidget">
<div><h4>${this.count}</h4></div>
<div>
<button @click="down" class="button-outline">DOWN</button>
<button @click="up" class="button-outline">UP</button>
</div>
</div>
</div>
@mardix
mardix / gist:c96e1ce96ba0f544d7dd21b50867d91f
Last active April 24, 2019 06:14
Python Package Development
View gist:c96e1ce96ba0f544d7dd21b50867d91f
## Create virtualenv
> mkvirtualenv $name
> workon $name
## Develop
To install
> python setup.py develop
View generateTemplateString.js
/**
* Produces a function which uses template strings to do simple interpolation from objects.
*
* Usage:
* var makeMeKing = generateTemplateString('${name} is now the king of ${country}!');
*
* console.log(makeMeKing({ name: 'Bryan', country: 'Scotland'}));
* // Logs 'Bryan is now the king of Scotland!'
*/
var generateTemplateString = (function(){
@mardix
mardix / DOMClass.js
Created December 8, 2018 21:23 — forked from Maksims/DOMClass.js
HTMLElement extension to add, remove, toggle, detect Classes.
View DOMClass.js
HTMLElement = typeof(HTMLElement) != 'undefiend' ? HTMLElement : Element;
HTMLElement.prototype.addClass = function(string) {
if (!(string instanceof Array)) {
string = string.split(' ');
}
for(var i = 0, len = string.length; i < len; ++i) {
if (string[i] && !new RegExp('(\\s+|^)' + string[i] + '(\\s+|$)').test(this.className)) {
this.className = this.className.trim() + ' ' + string[i];
}