Skip to content

Instantly share code, notes, and snippets.

@courajs
courajs / on_suspend.sh
Last active October 6, 2022 18:21
Run a command each time you suspend vim with ctrl+z
# Current unix time in millisecond
function ms() {
echo $(($(date +%s%N)/1000000))
}
# If we suspend vim (ctrl-z), run the on-suspend command and then
# re-foreground vim. If we exit fully, return to the shell.
function post_vim() {
# 148 status code indicate the previous command was suspended
if [ ! $? = 148 ]; then return; fi
@courajs
courajs / click.c
Created April 6, 2022 21:57 — forked from rsp/click.c
// Compile instructions:
//
// gcc -o click click.c -Wall -framework ApplicationServices
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int x = 0, y = 0, n = 1;
float duration = 0.1;

Keybase proof

I hereby claim:

  • I am courajs on github.
  • I am courajs (https://keybase.io/courajs) on keybase.
  • I have a public key ASDQM2f55XEJuta3q5dKF9ZHHjBEu2H4M0MKPvNrCiF8_go

To claim this, I am signing this object:

@courajs
courajs / chatServer.js
Created September 8, 2017 17:48 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
0x1E65F71b024937b988fdba09814d60049e0Fc59d
{{#each publications as |publication|}}
<h1>Hello, {{publication.name}}</h1>
{{else}}
No publications
{{/each}}
import Ember from 'ember';
const {
Component
} = Ember;
export default Component.extend({
willRender() {
this.set('timerStart', new Date());
},
@courajs
courajs / controllers.application.js
Created April 26, 2017 20:25 — forked from machty/controllers.application.js
ember-concurrency starter
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
myTask: task(function * () {
let didConfirm = yield this.get('getConfirmation').perform("Are you sure?");
if (didConfirm) {
alert("woot");
@courajs
courajs / components.hider-component.js
Last active April 16, 2017 21:08
Conditionally rendered components
import Ember from 'ember';
import through from '../indirect';
// Inlined, since no addons in twiddles. Really use this:
// import through from 'ember-computed-indirect/utils/indirect';
export default Ember.Component.extend({
user: Ember.inject.service('user-permissions'),
flagName: '', // specify in extending component
flagPath: Ember.computed('flagName', function() {
return 'user.' + this.get('flagName');
@courajs
courajs / controllers.application.js
Created April 12, 2017 13:25
Trampolined Properties
import Ember from 'ember';
let t = 0;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
theKey: 'one',
one: 1,
two: 2,