Skip to content

Instantly share code, notes, and snippets.

View rawman's full-sized avatar

Tomasz Romaniuk rawman

View GitHub Profile
class MarkObsoleteAppointmentsJobConsole
BATCH_SIZE = 100
def perform
latest_end_at = LastObsolete.first.end_at
logger = Logger.new("log/#{Rails.env}-obsolete.log")
appointments = Appointment.
from("appointments FORCE INDEX (index_appointments_on_end_at)").
includes(:appointment_contexts, :appointment_invitations, :appointment_associations).
defmodule IntegrationMonitor.FooBar do
def start_link do
import Supervisor.Spec
children = [supervisor(IntegrationMonitor.Foo, [], restart: :transient)]
Supervisor.start_link(children, strategy: :simple_one_for_one, max_restarts: 3, max_seconds: 20, name: __MODULE__)
end
def start_child do
def page(query, from, limit) do
from m in query,
where: m.id > ^from,
limit: ^limit
end
def to_stream(query, repo, page_size \\ 100) do
Stream.resource(
fn -> 0 end,
def map(collection, fun \\ &(&1)) do
map_impl(collection, &spawn/1, &(invoke(fun, &1)))
end
def map!(collection, fun \\ &(&1)) do
map_impl(collection, &spawn_link/1, fun)
end
defp map_impl(collection, spawn_fun, fun) do
me = self
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
rm /Users/roman/.config/.mono
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
for i in `ls -al | grep /Library/Frameworks/Mono.framework/ | awk '{print $9}'`; do
rm ${i}
done);
done
foreach(var user in users)
{
Console.WriteLine(user.Name);
}
users.ToObservable()
.Subscribe(x => Console.WriteLine(x.Name))
public interface IEnumerable<T>
{
@echo off
tasklist /FI "IMAGENAME eq hipchat.exe" 2>NUL | find /I /N "hipchat.exe">NUL
if "%ERRORLEVEL%"=="0" taskkill /f /im "hipchat.exe"
start /b /d "%ProgramFiles(x86)%\Atlassian\HipChat" hipchat.exe
exit
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
public static void Invoke(Func<int> func)
{
int result = 0;
try
{
result = func();
}
catch (Exception)
{
//oblsuga bledow
Set-WindowsExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst GoogleChrome
cinst VisualStudio2013Ultimate
cinst resharper
cinst notepadplusplus
cinst fiddler4
cinst dotpeek
cinst virtualbox