Skip to content

Instantly share code, notes, and snippets.

@sublipri
sublipri / telescope.lua
Last active December 26, 2023 15:17
A lazy.nvim configuration for telescope.nvim that enables cycling through pickers similar to Ctrl-P. Also implements a default picker that opens Buffers, Git Files or Oldfiles depending on the context.
local setup = function()
local telescope = require("telescope")
local actions = require("telescope.actions")
local builtin = require("telescope.builtin")
local get_total_buffers = function()
local bufnrs = {}
local i = 1
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.fn.buflisted(bufnr) == 1 then
@Deraen
Deraen / 00_notes.md
Last active October 1, 2019 08:40
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required
@adambard
adambard / errors.clj
Created May 13, 2013 05:48
An example of functional error handling in clojure.
(ns example.errors)
(defn clean-address [params]
"Ensure (params :address) is present"
(if (empty? (params :address))
[nil "Please enter your address"]
[params nil]))
(defn clean-email [params]
"Ensure (params :email) matches *@*.*"
@mattwynne
mattwynne / sketch.rb
Created June 23, 2012 22:22 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@lukemelia
lukemelia / sketch.rb
Created June 23, 2012 20:01
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
@jeffreyiacono
jeffreyiacono / Rakefile
Created February 8, 2012 20:15
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@ryanlecompte
ryanlecompte / gist:1420133
Created December 1, 2011 21:47
Alternative to modifying Proc directly
# alternative to what is explained in the article Ruby Blocks as Dynamic Callbacks:
# http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks
class Twitter
def tweet(msg, &block)
proxy = DSL[block]
publish(msg)
proxy.respond_with(:success)
rescue => e
proxy.respond_with(:failure, e.message)
@obfuscurity
obfuscurity / gist:1409152
Created November 30, 2011 14:00
Rakefile for blog post
# Rakefile
namespace :db do
require "sequel"
namespace :migrate do
Sequel.extension :migration
DB = Sequel.connect(ENV['DATABASE_URL'])
desc "Perform migration reset (full erase and migration up)"
task :reset do
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
require "minitest/autorun"
# inspired by some code from Chris Wanstrath (shared w. me by Ryan Smith)
# https://gist.github.com/25455
#
# heavily modified by Gregory Brown at this point..
def context(*args, &block)
return super unless (name = args.first) && block