Skip to content

Instantly share code, notes, and snippets.

export PS1='\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]$(__git_ps1)$ '
@ippa
ippa / todolist-mobx.js
Last active July 4, 2017 15:45
react-native meetup code samples
// -----------------------
// Store.js
import {observable, action, computed} from "mobx";
class Store {
@observable
todos = [
{title: "Skapa gdocs presentation", status: "active"},
{title: "Koda meetup-exempel", status: "active"},
{title: "Koda meetup-exempel #2", status: "active"},
<a href="liveapp://account">Konto</a>
#!/bin/bash
#
# Bash-script for easy switching between dev and prod settings in your xcode project
# Run in root of your project. Details: https://facebook.github.io/react-native/docs/running-on-device-ios.html
#
# ./xcode dev
# - Detects local IP and tells xcode to access packager live-bundling through that
# - Sets xcode build configuration to Debug
#
# ./xcode prod
@ippa
ippa / create_appicons.sh
Last active April 22, 2016 10:22
shell-script to create android icons w/ the right sizes
#!/bin/sh
if [ $# -eq 0 ]; then
echo "./appicon.sh <sourceimage> - Will resize and install appicon into correct directories"
exit 1
fi
CONVERT="/c/Program/ImageMagick/convert.exe"
PATH=."/android/app/src/main/res/"
@ippa
ippa / .vimrc
Last active February 29, 2016 02:07
.vimrc
autocmd FileType html setlocal indentkeys-=*<Return>
let g:html_indent_inctags = "html,body,head,tbody"
set bs=2
set smartindent autoindent smarttab
set shiftwidth=2
set background=dark
set ru
set tabstop=2
set expandtab
@ippa
ippa / gist:5605152
Last active December 17, 2015 11:49
rethinkdb braindump

Comming from raw SQL and then activerecord (ruby) this was my first impressions/thoughts on RethinkDB. It's just a quick braindump so take it for what it is :).

  • why not have RethinkDB::RQL#inspect call run() so I can play around easier in irb. Constructing queries and see the results directly. How useful is it really to have the query I just constructed printed again?

  • I was running 1.4.5 and "apt-get update" got me 1.5 and suddenly my database wasn't working. The package was released before the blogpost with migration-instructions. Edgecase, but I managed to get bitten by it :P. The log-entry could contain the url with migrations-instructions?

  • Why not just order() instead of order_by(), you don't have filter_by() or replace_with(). Maybe I'm colored by active record in this case.. but less is usually more. Hard to confuse a simpler order() with anything else.

  • r.connect should take a hash/json argument. Then I could do r.connect(db: "heroes"), host would default to localhost and port to 28015 as n

@ippa
ippa / gist:965662
Created May 11, 2011 00:14
svetlo-modified
// Modified: http://www.vcarrer.com/2011/04/svetlo-one-line-javascript-selector.html
function $(selector){
var elements = Array.prototype.slice.call( document.querySelectorAll(selector) )
var items = selector.split(" ")
return (items[items.length-1][0] == "#") ? elements[0] : elements // Return single element if fetching an ID
}
Sprite.prototype.createInDOM = function() {
this.dom_element = this.image
this.dom_element.style.position = "absolute"
document.body.appendChild(this.dom_element)
this.updateDOM()
}
Sprite.prototype.updateDOM = function() {
this.dom_element.style.left = this.x + "px"
this.dom_element.style.top = this.y + "px"
# client
@ip = "127.0.0.1"
@socket = UDPSocket.new
@socket.connect(@ip, SERVER_PORT)
def send_to_server(data = {})
packed = Marshal.dump(data)
@socket.send(packed, 0)
end