This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Zla liczba argumentow" | |
else | |
for user in `who | cut -d' ' -f1 | uniq`; do | |
for group in `groups $user`; do | |
if [ $group == $1 ]; then | |
echo $user | |
fi | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ack -oh '\bt\("([^"]*)".*:default => "([^"]*)"' --output="\$1: \\\"\$2\\\"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun next-generation (board) | |
(loop for row being the elements of board using (index x) collect | |
(loop for col being the elements of row using (index y) collect | |
(next-cell-p x y board)))) | |
(defun next-cell-p (x y board) | |
(let ((count (neighbours-count x y board)) | |
(cell (cell-p x y board))) | |
(or | |
(and cell (or (= count 2) (= count 3))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
pictures = ARGV.map(&:to_i).sort | |
desired_group_size = ENV["GROUP_SIZE"].to_i | |
min_distance, max_distance = pictures.each_cons(2).map { |a, b| b - a }.minmax | |
groups = pictures.map { |picture| [picture] } | |
# Calculates distance factor using linear function. | |
# | |
# 1.0 when distance == min_distance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserMailer < ActionMailer::Base | |
# ... | |
def daily_news(user) | |
mail(to: user.email, subject: "Daily newsletter") | |
end | |
private | |
def accepts_delivery?(address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun activesupport-camelize (string &rest args) | |
"camelizes string just like in ActiveSupport inflector" | |
(and (= 0 (length args)) (setq args '(t))) | |
(reduce (lambda (string replacement) | |
(replace-regexp-in-string (car replacement) (cadr replacement) string)) | |
'(("^." (lambda (match) (upcase match))) | |
("_." (lambda (match) (upcase (substring match 1)))) | |
("/.?" (lambda (match) (concat "::" (upcase (substring match 1)))) string)) | |
:initial-value string | |
:start (if (car args) 0 1))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start on startup | |
exec /usr/local/bin/scanner.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun activesupport-underscore (string) | |
"underscores string just like in ActiveSupport inflector" | |
(let ((case-fold-search nil)) | |
(downcase | |
(reduce (lambda (string replacement) | |
(replace-regexp-in-string (car replacement) (cadr replacement) string)) | |
'(("::" "/") | |
("\\([[:upper:]]+\\)\\([[:upper:]][[:lower:]]\\)" "\\1_\\2") | |
("\\([[:lower:][:digit:]]\\)\\([[:upper:]]\\)" "\\1_\\2") | |
("-" "_")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.active_record.whitelist_attributes = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table1 = { | |
table: { | |
"id": 1, | |
"version": 5, | |
"players": [ | |
{ "id": 1, name: "user N", direction: "N" }, | |
{ "id": 2, name: "user E", direction: "E" }, | |
{ "id": 3, name: "user S", direction: "S" }, | |
{ "id": 4, name: "user W", direction: "W" } | |
], |