Skip to content

Instantly share code, notes, and snippets.

View alaz's full-sized avatar

Alexander Azarov alaz

View GitHub Profile
@walkerjeffd
walkerjeffd / Synology-Diskstation-Git.md
Last active April 27, 2024 15:39
Instructions for setting up git server on Synology Diskstation

Configure Synology NAS as Git Server

Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.

Set Up User and Folder

  • Create user gituser via Diskstation interface (with File Station and WebDAV privilages)
  • Add new shared folder called git (located at /volume1/git) with read/write access for gituser and admin. This folder will hold all the repos.
  • Install Git Server package via Diskstation
@youngbrioche
youngbrioche / images_helper.rb
Last active February 8, 2024 08:15
Responsive images helper using srcset in Rails
module ImagesHelper
# Acts as a thin wrapper for image_tag and generates an srcset attribute for regular image tags
# for usage with responsive images polyfills like picturefill.js, supports asset pipeline path helpers.
#
# image_set_tag 'pic_1980.jpg', { 'pic_640.jpg' => '640w', 'pic_1024.jpg' => '1024w', 'pic_1980.jpg' => '1980w' }, sizes: '100vw', class: 'my-image'
#
# => <img src="/assets/ants_1980.jpg" srcset="/assets/pic_640.jpg 640w, /assets/pic_1024.jpg 1024w, /assets/pic_1980.jpg 1980w" sizes="100vw" class="my-image">
#
def image_set_tag(source, srcset = {}, options = {})
srcset = srcset.map { |src, size| "#{path_to_image(src)} #{size}" }.join(', ')
@tispratik
tispratik / override_cache_key.rb
Last active February 13, 2022 08:50
Override cache key and touch methods in active record when we cannot update the last modified / updated at column in database. We keep track of the changes in memcache.
module CacheKeyMonkeyPatch
module ActiveRecord
module Integration
# Returns a cache key that can be used to identify this record.
#
# ==== Examples
#
# Product.new.cache_key # => "products/new"
# Product.find(5).cache_key # => "products/5" (updated_at / last_modified_time not available)
@leon
leon / Grunt.scala
Last active September 3, 2016 02:23
Playframework 2.2 Grunt Runner
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
@DeaconDesperado
DeaconDesperado / Bloom.scala
Last active January 30, 2017 10:18
Trivial bloom filter implementation in Scala.
class BloomSet[A] private (val size: Int, val k: Int,private val contents: Vector[Boolean]){
val width = contents.length
def this(width: Int, k: Int) = this(0, k, BloomSet.alloc(width))
def contains(e:Any) = {
(0 to k).foldLeft(true) { (acc,i) =>
acc && contents(hash(e,i,width))
}
@milessabin
milessabin / gist:6240282
Last active December 21, 2015 03:09
Module with a single function entry point and some associated types which aren't always needed. Useful idiom or too cute?
scala> :paste
// Entering paste mode (ctrl-D to finish)
// tag is a module which can be imported from, but also, thanks to its apply method and Scala's
// syntactic sugar, a function-like value which can be invoked directly.
object tag {
def apply[U] = new Tagger[U]
trait Tagged[U]
type @@[+T, U] = T with Tagged[U]
@stex
stex / field_error_proc.rb
Created May 8, 2013 11:23
Rails field_error_proc to add an error class to invalid input fields
#Overrides the default way how rails marks form fields with errors.
#In this version, it only adds the class 'error' to label and element
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<(input|label|textarea|select)/
html_field = Nokogiri::HTML::DocumentFragment.parse(html_tag)
html_field.children.add_class 'error'
html_field.to_s
else
html_tag
@adamloving
adamloving / temporary-email-address-domains
Last active April 24, 2024 14:20
A list of domains for disposable and temporary email addresses. Useful for filtering your email list to increase open rates (sending email to these domains likely will not be opened).
0-mail.com
0815.ru
0clickemail.com
0wnd.net
0wnd.org
10minutemail.com
20minutemail.com
2prong.com
30minutemail.com
3d-painting.com
@josephwecker
josephwecker / new_bashrc.sh
Created August 11, 2012 04:36
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?