Skip to content

Instantly share code, notes, and snippets.

View beshrkayali's full-sized avatar

Beshr Kayali Reinholdsson beshrkayali

View GitHub Profile
@bohde
bohde / tags.py
Created January 30, 2012 03:25
Using django-taggit with django-tastypie
from tastypie.fields import ListField
class TaggedResource(ModelResource):
tags = ListField()
class Meta:
queryset = Model.objects.all()
def build_filters(self, filters=None):
if filters is None:
@maglar0
maglar0 / Makefile
Created March 25, 2014 14:03
Makefile for building a React.js project using JSX and almond, while using requirejs and JSXTransformer during development. See discussion at https://github.com/seiffert/require-jsx/issues/1
NODE_MODULES=../node_modules
JSX=$(NODE_MODULES)/react-tools/bin/jsx
R=$(NODE_MODULES)/requirejs/bin/r.js
BUILD_JSX=build/jsx
SOURCE_JSX=js2/app/jsx
BUILD_APP=build/app
SOURCE_APP=js2/app
BUILD_LIB=build/lib
@Meiguro
Meiguro / simplyjs-accel-demo.js
Created February 16, 2014 07:20
Here's a Simply.js demo showing accelerometer support.
simply.text({
title: 'Accel Demo',
body: 'Press up to stream or select to peek.',
}, true);
/**
* Use simply.accelConfig({ rate: 100, samples: 25 }) to configure
* the hertz and accel data per batch for the accelData events.
* See the API reference at simplyjs.io for more information.
*/
@joar
joar / lib-tty.py
Last active November 21, 2017 12:26
"""Terminal utilities."""
# Author: Steen Lumholt.
from termios import *
__all__ = ["setraw", "setcbreak"]
# Indexes for termios list.
IFLAG = 0
@hopewise
hopewise / English To Hindi
Last active February 6, 2019 03:16
This script will replace all English numbers by Hindi numbers, it uses regular expression that exclude numbers between tags, ex: <h3>
<script type="text/javascript">
var replaceDigits = function() {
var map = ["&#x660;","&#x661;","&#x662;","&#x663;","&#x664;", "&#x665;","&#x666;","&#x667;","&#x668;","&#x669;"]
// replace english floating point with arabic one:
document.body.innerHTML = document.body.innerHTML.replace(/\d(?=[^<>]*(<|$))/g, function($0) { return map[$0]});
// replace english floating point with arabic one:
document.body.innerHTML = document.body.innerHTML.replace(/\.(?=[^<>]*(<|$))/g, "&#x066B;");
}
window.onload = replaceDigits;
</script>
@sharpner
sharpner / goclone
Created August 14, 2015 09:32
clone and symlink go open source project
#/!bin/bash
repository=github.com
if [ -z "$GOPATH" ] ; then
echo '$GOPATH not set.'
exit 1
fi
cd $GOPATH
@goldsmith
goldsmith / python_mavericks_guide.sh
Last active June 3, 2020 12:18
When I upgraded my Mac to OS X Mavericks, a lot of utilities (like Python, virtualenv, Xcode) broke, and it was pretty stressful trying to get it all set back up. Hopefully this guide can spare you some of that pain.Note: I'm by no means a Linux or Mac expert, so please fork and let me know if anything is redundant, incorrect, or missing!
# A guide to prevent pain and suffering while upgrading to OS X Mavericks
# This will vary greatly depending on system set up, so read the instructions carefully
# Back up Virtulenvs
####################
# Very important!
# For each virtualenv you have, run "pip freeze > requirements.txt" while in the activated virtualenv
# in order to prevent loss of dependencies during the upgrade.
function countPieces() {
it = b.pieces();
var i = 0;
while (it.current()){ i++; it.next() }
return i;
}
function getRandPiece() {
var it = b.pieces();
var n = Math.floor(Math.random()*countPieces());
@jessykate
jessykate / django-crossdomainxhr-middleware.py
Created June 16, 2012 12:44 — forked from vicalejuri/django-crossdomainxhr-middleware.py
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
'''
EXAMPLE USAGE:
Put this file in a directory called, eg, 'middleware,' inside your django
@beshrkayali
beshrkayali / poly-pio-mode.el
Created February 19, 2021 20:35
Poly RaspberryPi PIO mode
;; Simple Polymode for RaspberryPi Pico PIO files that uses
;; both asm-mode as host-mode and c-mode for pass-through section
(define-hostmode poly-pio-hostmode
:mode 'asm-mode)
(define-auto-innermode poly-pio-c-innermode
:mode 'c-mode
:head-matcher "^% c-sdk {$"
:tail-matcher "^%}$"