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
# To release pypi package | |
alias pypi-publish='python setup.py register -r pypi && python -m twine upload dist/*' |
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
## Create virtualenv | |
> mkvirtualenv $name | |
> workon $name | |
## Develop | |
To install | |
> python setup.py develop |
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
<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> |
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
<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"> |
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
<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> |
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
/** | |
* 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(){ |
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
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]; | |
} |
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
While I was working on a personal project, I decided to compare foreach vs array_map to iterate over a large set of items. | |
So to support my decision, I ran a benchmark on both foreach and array_map. | |
With a simple array of 1,000,000 objects, I iterate over them with foreach and array_map. And surprisingly, foreach ran in 0.24sec average, while array_map took over 3.30sec. | |
Also array_map ran out of memory, I had to do an ini_set("memory_limit","512M"); to at least get some results. | |
My system: | |
Macbook |
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.pythonPath": "/Users/Mardix/.virtualenvs/${workspaceRootFolderName}/bin/python" | |
} |
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 frontmatter | |
from frontmatter import Post as FMPost | |
def frontmatter_to_file(file, data={}, content=""): | |
p = FMPost(content=content, **data) | |
with open(file, "w") as f: | |
f.write(frontmatter.dumps(p)) |