Skip to content

Instantly share code, notes, and snippets.

@carlaviktor
carlaviktor / .zshrc
Created March 22, 2020 01:06 — forked from gfguthrie/.zshrc
Lazy Load Homebrew NVM but still have default aliased Node in PATH
# normal brew nvm shell config lines minus the 2nd one
# lazy loading the bash completions does not save us meaningful shell startup time, so we won't do it
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
# add our default nvm node (`nvm alias default 10.16.0`) to path without loading nvm
export PATH="$NVM_DIR/versions/node/v$(<$NVM_DIR/alias/default)/bin:$PATH"
# alias `nvm` to this one liner lazy load of the normal nvm script
alias nvm="unalias nvm; [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"; nvm $@"
@carlaviktor
carlaviktor / brew-dnsmasq.md
Created February 27, 2019 11:31 — forked from davebarnwell/brew-dnsmasq.md
install dnsmasq with brew

Install dnsmasq and configure for *.dev.local domains

$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf

Reload configuration and clear cache

# Copy the daemon configuration file into place.
$ sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/

$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

class HomeView extends React.Component {
state = {
modalVisible: false
};
setModalVisible = visible => {
this.setState({ modalVisible: visible });
};
render() {
return (
<Background>
const testPageJSON = {
"children": [
{
"el": "div",
"props": {
"style": {
"background": "green"
}
},
"children": [

Array(10) skapar en behållare med 10 fack som är tomma: [ingenting, ingenting, ingenting, ingenting, ingenting, ingenting, ingenting, ingenting, ingenting, ingenting]

@carlaviktor
carlaviktor / Window.react.js
Created October 25, 2015 12:57
React Window Component
<Window onLocationChange=“” onResize=“”>
<App controller=“(state, actions)” />
</Window>
@carlaviktor
carlaviktor / .bash_profile
Last active October 19, 2015 17:25
Config files
# Colors
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
@carlaviktor
carlaviktor / It's OK not to use tools.md
Last active October 3, 2015 18:21
It's OK not to use tools
class Completion < ActiveRecord::Base
# columns: completable_type, completable_id, id, created_at
belongs_to :completable, polymorphic: true
end
class Task < ActiveRecord::Base
@carlaviktor
carlaviktor / gist:0b3e7fb2aa4b6c01ac8a
Last active August 29, 2015 14:02
Tell, Don't Ask example
# Better
class Post
def send_to_feed
user.send_to_feed(contents)
end
end
# Is this better or worse?
class Post
def send_to_feed