Skip to content

Instantly share code, notes, and snippets.

View onsails's full-sized avatar
You only truly know it when you truly feel it

Andrey Kuznetsov onsails

You only truly know it when you truly feel it
View GitHub Profile
@onsails
onsails / gist:10119638
Last active August 29, 2015 13:58
Simple nooby sitemap printer sample
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import Text.XML.Light
import Control.Monad.Trans (liftIO)
import Control.Monad
import Data.String.Utils
import Control.Exception
import Control.Monad.Trans.Resource
import Control.Monad.Trans.Class
@onsails
onsails / gist:1fb526ac1cbddcd63bef
Created June 2, 2015 17:16
Deferred notifications demo
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>notif</title>
</head>
<body id="notif" onload="">
<input id="new-notif" type="button" value="Show notification"/>
<script type="text/javascript">
'use strict';
1 require "rubygems"
2 require 'adhearsion'
3 require 'adhearsion/voip/asterisk/manager_interface'
4 class DropsController < ApplicationController
5 include Adhearsion::VoIP::Asterisk::Manager
6 include Adhearsion::VoIP::Asterisk::Commands
7 AMI_SERVER = "localhost"
8 AMI_USER_NAME = "admin"
9 AMI_PASSWORD = "amp111"
10 def show
# encoding utf-8
ROWS = 2
words = []
maxlength = 0
File.open("words.txt", "r") do |f|
f.each_line do |l|
# lib/daemon.rb
class Daemon < DaemonSpawn::Base
def start args
while true
# ... функциональная часть
sleep 3600
end
end
namespace :daemon do
task :restart do
run <<-CMD
cd #{latest_release};
RAILS_ENV=production script/cron stop;
RAILS_ENV=production script/cron start;
CMD
end
end
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"
File.open "log/daemon.log", "w" if !File.exists? "log/daemon.log"
Daemon.spawn! :log_file => "#{RAILS_ROOT}/log/daemon.log",
:pid_file => "#{RAILS_ROOT}/tmp/pids/daemon.pid",
:sync_log => true,
File.open("/etc/passwd").each_line do |line|
arr = line.split(":")
puts "#{arr.first} - #{arr.last}"
end
File.open("/etc/passwd") do |io|
io.each_line do |line|
arr = line.split(":")
puts "#{arr.first} - #{arr.last}"
end
<?php
echo <<<EOS
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="My sponsors" />
<Content type="html">
<![CDATA[
<div style="background-color: #710;">
EOS;
if (!defined('_SAPE_USER')){
# :%s/%appname%/_appname_/g
# :%s/%appname%/_username_/g
# :%s/%domain%/_domain_/g
set :application, "%appname%"
set :repository, "git@github.com:smix/%appname%.git"
set :deploy_to, "/var/rails/%appname%"
set :deploy_via, :remote_cache
set :branch, 'master'
set :scm, :git