Skip to content

Instantly share code, notes, and snippets.

View christianhellsten's full-sized avatar
🛰️
In space

Christian Hellsten christianhellsten

🛰️
In space
  • https://aktagon.com
  • 05h 38m 38s, −69° 5.7′ 0″, 160 ± 10 k ly (In space)
View GitHub Profile
@christianhellsten
christianhellsten / Cargo.toml
Created January 1, 2024 18:48
OpenAI API completion using Rust
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2021"
rust-version = "1.60"
@christianhellsten
christianhellsten / main.yml
Last active December 29, 2017 13:57
Install Redis from source on Ubuntu 16.04 with Ansible
---
- set_fact:
redis_version: 4.0.6
redis_sha256: 769b5d69ec237c3e0481a262ff5306ce30db9b5c8ceb14d1023491ca7be5f6fa
- get_url:
url: http://download.redis.io/releases/redis-{{redis_version}}.tar.gz
dest: /usr/local/src/
sha256sum: "{{redis_sha256}}"
register: get_redis_result
# Q sample by Jeff Cogswell
#===========
# We want to call these three functions in sequence, one after the other:
#
# First we want to call one, which initiates an ajax call. Once that ajax call
# is complete, we want to call two. Once two's ajax call is complete, we want to call three.
#
# BUT, we don't want to just call our three functions in sequence, as this quick
# demo will show. Look at this sample function and think about what order
@christianhellsten
christianhellsten / unicorn
Created October 15, 2012 18:42 — forked from shapeshed/unicorn
Unicorn / Monit setup
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@christianhellsten
christianhellsten / active_record_translate.rb
Created May 1, 2011 19:09
i18n for ActiveRecord with fallback support
#
# Usage:
# translate :title, :link, { :fallback => true, :locales => [:en, :sv, :fi] }
#
module ActiveRecordTranslate
def self.method_definition(column_name, options)
fallback_method = "nil"
if options[:fallback] && options[:locales].try(:size) > 1
locales = options[:locales].map {|l| %Q{:"#{l}"} }.join(',')
@christianhellsten
christianhellsten / active_record_translate.rb
Created February 15, 2011 19:46
i18n for ActiveRecord?
module ActiveRecordTranslate
def self.included(base)
base.send :include, InstanceMethods
base.extend ClassMethods
end
module ClassMethods
def translated_column_name(name)
:"#{name}_#{I18n.locale}"
end
@christianhellsten
christianhellsten / Taggable.rb
Created September 29, 2010 18:30
Tag ActiveRecord models
module Taggable
def self.included(base)
base.send :include, InstanceMethods
base.extend ClassMethods
end
module ClassMethods
def initialize(collection_names)
delimiter = ','