Skip to content

Instantly share code, notes, and snippets.

View bartek's full-sized avatar
🐗

Bartek Ciszkowski bartek

🐗
View GitHub Profile
@bartek
bartek / gist:4670192
Last active April 6, 2019 21:08
Postgres memory optimization

After some reading and help from #postgresql. I settled on these changes to my memory settings in postgresql.conf. This is on a box with 8gb of ram and 2 cpus.

shared_buffers = 1GB
work_mem = 128MB
maintenance_work_mem = 256MB
effective_cache_size = 6GB

For kernel settings, I did this:

kernel.shmmax=1288490000

#index.html
<!-- Start javascript/main.js -->
<script src='./javascript/public/lodash.js'></script>
<script src="./javascript/public/yabble.js"></script>
<script src="./javascript/public/gamejs.min.js"></script>
<script>
require.setModuleRoot('./javascript/');
require.run('main')
</script>
var __scripts = ["http://127.0.0.1:4000/javascript/public/lodash.js","http://127.0.0.1:4000/javascript/public/yabble.js","http://127.0.0.1:4000/javascript/public/gamejs.min.js"];
__scripts.forEach(function(script) {
try {
importScripts(script);
} catch (e) {
// can't help the worker
}
});
self.require.setModuleRoot("http://127.0.0.1:4000/javascript/");self.require.run("./gramework/gamepad");
var gamejs = require('gamejs');
var handleEvent = function(data) {
gamejs.log("Ugh", data);
};
gamejs.ready(function() {
gamejs.onEvent(handleEvent);
});

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

diff --git a/src/template-jasmine-requirejs.js b/src/template-jasmine-requirejs.js
index ddb021d..1ecdb54 100644
--- a/src/template-jasmine-requirejs.js
+++ b/src/template-jasmine-requirejs.js
@@ -56,8 +56,15 @@ exports.process = function(grunt, task, context) {
// Remove baseUrl and .js from src files
var baseUrl = (context.options.requireConfig && context.options.requireConfig.baseUrl || '/');
+ var paths = (context.options.requireConfig && context.options.requireConfig.paths || {});
+
from django.db.models.query import QuerySet
from django.db import models
class QuerySetManager(QuerySet):
'''
Subclass this class to define custom Managers with chainable, custom
QuerySet calls.
For example, define your queryset subclassing this object:
{
"name": "profile",
"version": "0.0.1",
"description": "Profile application, codenamed MyG",
"main": "app/main.js",
"browserify-shim": {
"backbone": "Backbone",
"backbone-nested": {"depends": ["backbone"]}
},
"browserify": {
@bartek
bartek / dict_to_xml.py
Created April 17, 2014 19:39
Convert a list of dictionaries into an XML representation
from xml.etree.ElementTree import Element, SubElement
def dict_to_xml(data, root_name='events'):
# a list of dictionaries, converted into xml.
root = Element(root_name)
def _make_xml(i_root, data_dict):
for field, val in data_dict.iteritems():
if isinstance(val, dict):
i_data = SubElement(i_root, field)
function getSomethingMagicalFromRemote() {
var obj = cache.get('obj-key');
if (typeof obj =!="undefined")
return obj
}
// Otherwise init ajax call
$.ajax({ .... })
}