This is now an actual repo:
<?php | |
// Snippet for Symfony 2 application that uses Doctrine 2 to handle transactions | |
// It uses the names of the objects/doctrine repositories from the Beta 4 Manual of Symfony 2. | |
// Get the entity manager | |
$em = $this->getDoctrine()->getEntityManager(); | |
// suspend auto-commit | |
$em->getConnection()->beginTransaction(); |
A timeline of the last four years of detecting good old window.localStorage
.
October 2009: 5059daa
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
// This event emitter emits events, but reserves the right to publish events to | |
// for its creator. It uses a WeakMap for true encapsulation. | |
const eesToEventMaps = new WeakMap(); | |
export default class EventEmitter { | |
constructor(publisher) { | |
const eventMap = Object.create(null); | |
eesToEventMaps.set(this, eventMap); |
A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.
python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
To remove a submodule you need to:
- Delete the relevant section from the .gitmodules file.
- Stage the .gitmodules changes git add .gitmodules
- Delete the relevant section from .git/config.
- Run git rm --cached path_to_submodule (no trailing slash).
- Run rm -rf .git/modules/path_to_submodule (no trailing slash).
- Commit git commit -m "Removed submodule "
- Delete the now untracked submodule files rm -rf path_to_submodule
This is an example of using a jquery plugin (in this case semantic ui) via requirejs WITHOUT needing to rely on the plone bundling infrastructure.
Update: Dec 16, 2015
http://github.com/thet pointed out an alternative approach which reduces the number of files used by getting rid of main.js
and putting all the code in app.js
like this:
require.config({ "baseUrl": "./", "paths": {
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
from datetime import datetime, timedelta | |
import functools | |
def timed_cache(**timedelta_kwargs): | |
def _wrapper(f): | |
update_delta = timedelta(**timedelta_kwargs) | |
next_update = datetime.utcnow() + update_delta | |
# Apply @lru_cache to f with no cache size limit |