Skip to content

Instantly share code, notes, and snippets.

View Tehnix's full-sized avatar
🌞
Enjoying the code...

Christian Kjær Tehnix

🌞
Enjoying the code...
View GitHub Profile
@Tehnix
Tehnix / func.vim
Last active September 17, 2016 16:11
Perform a git pull to update the layers repository
function! s:scratch_buffer()
rightbelow new
setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile
return bufnr('%')
endfunction
let s:update_output = ["Updating SpaceNeovim layers"]
function! s:update_job_control(job_id, data, event)
if a:event == 'stdout' || a:event == 'stderr'
let s:update_output += a:data
@Tehnix
Tehnix / NetworkExample.hs
Created July 12, 2016 19:28
Example of networking with a server and client (as bonus it also uses forkIO for threading and MVar's for thread communication).
module Main where
import Control.Monad (unless)
import Network.Socket hiding (recv)
import qualified Data.ByteString as S
import qualified Data.ByteString.Char8 as C
import Network.Socket.ByteString (recv, sendAll)
import Control.Concurrent (forkIO)
import Control.Concurrent.MVar (takeMVar, putMVar, newEmptyMVar, MVar)
@Tehnix
Tehnix / tellslack.sh
Created April 28, 2016 23:02
Include the file with `. tellslack.sh` and use with `tellslack "Hey! I'm awesome :D`
#!/usr/bin/env bash
# Configuration
slackhook="https://hooks.slack.com/services/TOKEN/TOKEN"
emoji=":nerd_face:"
username="backup-bot"
channel="backups"
function tellslack () {
curl -X POST --data-urlencode "payload={\"channel\": \"$channel\", \"username\": \"$username\", \"text\": \"$1\", \"icon_emoji\": \"$emoji\"}" $slackhook
@Tehnix
Tehnix / test.php
Last active February 2, 2016 23:53
Calling helper from other extension
// Myname/Core/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Myname_Core>
<version>0.1.0</version>
</Myname_Core>
</modules>
<global>
@Tehnix
Tehnix / amp.md
Last active November 25, 2015 09:25
Comment in a thread on /r/haskell on motivating AMP -- Originally from https://www.reddit.com/r/haskell/comments/3tpom7/amp_how_do_you_motivate_this_in_teaching/cx8an8b

You can naturally extend the intuition of a functor to Applicative, and from there to a monad.

An explanation might go as follows:

Let's say I have a list of numbers and want to add 2 to each. I'd 
write fmap (+2) [1..10]. But what if I had two lists of numbers and 
wanted to add each number from the first to each number from the second? 
Well, with Applicative, you can do that - it's like fmap, but with 
multiple arguments. You just write (+) &lt;$&gt; [1..10] &lt;*&gt; [11..20].
@Tehnix
Tehnix / install-anope.sh
Last active November 14, 2015 19:54
Bash script to install Anope IRC Services 2.0.2 on an AWS Linux AMI.
# This script will install Anope IRC Services on an AWS Linux AMI by:
# 0.1) Create an AWS Linux EC2 instance, with S3 read access (IAM roles))
# 0.2) Set up UnrealIRCd
# 1) Installing the necessary packages with yum
# 2) Downloading anope
# 3) Configuring and installing anope
# 4.1) Download configuration files from S3, add init script and start it
# 4.2) Alternatively, do it manually
#
# S3 assumes the file is called anope-$ANOPE_VERSION-rc3-conf.tar.gz, and is unpacked to
@Tehnix
Tehnix / install-unrealircd.sh
Last active November 14, 2015 19:52
Bash script to install UnrealIRCd 4.0.0 RC3 on an AWS Linux AMI.
# This script will install UnrealIRCd 4.0.0 RC3 on an AWS Linux AMI by:
# 0) Create an AWS Linux EC2 instance, with S3 read access (IAM roles))
# 1) Installing the necessary packages with yum
# 2) Downloading unrealircd
# 3) Configuring and installing unrealircd
# 4) Generating SSL certificates
# 5.1) Download configuration files from S3, add init script and start it
# 5.2) Alternatively, do it manually
#
# S3 assumes the file is called $UNREAL_VERSION-rc3-conf.tar.gz, and is unpacked to
@Tehnix
Tehnix / migration-plan.md
Last active January 12, 2016 18:22
Codetalk IRC to Slack migration plan

Motivation

We are currently running a somewhat half-assed IRC<->Slack integration which clutters the messages, from Slack->IRC, with '_: message'. This makes the backlog a bit tedious to read.

The IRC<->Slack integration also lacks support for some of the Slack features, like image uploading etc (i.e. there's no notification in IRC when an image is uploaded to Slack).

Proposal

The proposal is then to move to Slack entirely, and use their IRC Gateway for the people that prefer to use their IRC clients instead of the Slack client (which includes myself, terminals <3).

Advantages

@Tehnix
Tehnix / Package list
Created August 31, 2015 12:17
A list of extra packages that need to be installed when trying to use Hakyll in the FP Complete IDE
Hackage: network 2.6.2.1
Hackage: network-uri 2.6.0.3
Hackage: lrucache 1.2.0.0
Hackage: cmark 0.4.1
Hackage: haddock-library 1.2.1
Hackage: highlighting-kate 0.6
Hackage: hslua 0.4.0
Hackage: texmath 0.8.3
Hackage: time-locale-compat 0.1.1.0
Hackage: aeson 0.9.0.1

Keybase proof

I hereby claim:

  • I am tehnix on github.
  • I am tehnix (https://keybase.io/tehnix) on keybase.
  • I have a public key whose fingerprint is 9115 C8C2 4E10 79AE C7B0 0A7B 04EB 0696 6FFF 8531

To claim this, I am signing this object: