Skip to content

Instantly share code, notes, and snippets.

@mneumegen
mneumegen / cloudcannon.conf.yaml
Created March 16, 2022 04:12
CloudCannon input for themify icons
collections_config:
pages:
_enabled_editors:
- visual
posts:
_enabled_editors:
- content
- visual
_inputs:
@mneumegen
mneumegen / a.rb
Last active March 22, 2016 21:40
require 'json'
input = "[[0,5,6,11,15],[12,24,63],[17,28,50]]"
input = JSON.parse(input)
start = Time.now
min_column = input.map{|a| a[0]}
max = min_column.max
second_smallest = min_column.sort[1]
@mneumegen
mneumegen / gist:1694b664cc0fd40b5b20
Last active August 29, 2015 14:21
Out JSON in Jekyll
---
layout: null
---
[
{% for doc in site.docs %}
{
"title": "{{ doc.title | xml_escape }}",
"description": "{{doc.description | xml_escape }}",
"type": "{{doc.type | xml_escape}}"
@mneumegen
mneumegen / not_friends.rb
Created August 4, 2011 22:42
Not Friends
User.joins("LEFT OUTER JOIN friendships ON \
(friendships.user_id = #{current_user.id} AND friendships.friend_id = users.id) OR \
(friendships.user_id = users.id AND friendships.friend_id = #{current_user.id})")
.where("friendships.id IS NULL")
@mneumegen
mneumegen / time_parse.rb
Created May 31, 2011 00:13
Trying to parse a time including milliseconds
Time.strptime("2011-05-21 04:20:46.011", "%Y-%m-%d %H:%M:%S.%3N")
@mneumegen
mneumegen / date_intersect.rb
Created May 16, 2011 23:53
Date intersection
def self.date_intersect(start_date, end_date)
where("(start_time BETWEEN ? AND ?) OR \
(end_time BETWEEN ? AND ?) OR \
(start_time >= ? AND end_time <= ?)", start_date, end_date, start_date, end_date, start_date, end_date)
end