Skip to content

Instantly share code, notes, and snippets.

View meritt's full-sized avatar
🎯
Focusing

Alexey Simonenko meritt

🎯
Focusing
View GitHub Profile
@meritt
meritt / language.rb
Created December 30, 2009 12:00
Определение языка строки
framework 'Foundation'
class String
def language
CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0, self.size))
end
end
puts "Happy new year!".language
# => "en"
puts "С новым годом!".language
# This is how you can get a user's location using MacRuby and CoreLocation
framework 'CoreLocation'
def locationManager(manager, didUpdateToLocation: new_location, fromLocation: old_location)
puts "location: #{new_location.description}"
exit
end
loc = CLLocationManager.alloc.init
loc.delegate = self
// All elements which match this will be syntax highlighted.
var selector = 'code';
var keywords = ('var function if else for while break switch case do new '
+'continue delete return this true false throw catch typeof').split(' ');
// Syntax definition
// The key becomes the class name of the <span>
// around the matched block of code.
var syntax = {
// Если localStorage доступен, используем его
if (('localStorage' in window) && window.localStorage !== null) {
localStorage.taglist = '["#html5","#css3","#simonenko"]';
} else {
// если старый браузер, используем Cookie.
var date = new Date();
date.setTime(date.getTime() + (365*24*60*60*1000));
document.cookie = 'taglist=["#html5","#css3","#simonenko"]; expires=' + date.toGMTString() + '; path=/';
}
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
(function () {
function each(list, fn) {
var l = list.length;
@meritt
meritt / geolocation.js
Created April 18, 2011 10:19
Google Maps + Geolocation + Маршруты
if (navigator.geolocation) {
// #showroute это id кнопки/ссылки на сайте, нажимая которую мы должны проложить маршрут
var showroute = document.getElementById('showroute');
showroute.addEventListener('click', function(event) {
event.preventDefaults();
// пока строится маршрут не разрешаем нажимать на кнопку/ссылку снова
if (!showroute.classList.contains('disabled')) {
showroute.classList.add('disabled');
@meritt
meritt / async.coffee
Created July 19, 2011 06:04 — forked from tcr/async.coffee
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0
@meritt
meritt / tumblr.coffee
Created July 28, 2011 11:38
Example of usage for node-tumblr
Tumblr = require('tumblr').Tumblr
blog = new Tumblr 'simonenko.tumblr.com', 'OAuth Consumer Key'
blog.text limit: 2, (error, response) ->
throw new Error error if error
console.log response.posts
blog.link limit: 10, tag: "javascript", (error, response) ->
throw new Error error if error
@meritt
meritt / social.js
Last active September 27, 2015 12:07
Асинхронный код для социальной кнопки ВКонтакте
(function(w, d) {
// В этот массив можно вставить и другие социальные плагины, например: Google+, Facebook, Twitter
var u = ['//vk.com/js/api/openapi.js?75'],
i = u.length,
n = 'script',
f = d.createDocumentFragment(),
e = d.createElement(n),
t;
@meritt
meritt / deploy.rb
Created November 1, 2011 22:21
Capistrano config for NodeJS application
set :application, "simonenko.su"
set :node_file, "server.coffee"
set :host, "178.79.189.200"
set :repository, "[email protected]:meritt/simonenko.su.git"
set :user, "root"
set :admin_runner, "www"
set :scm, :git
set :branch, "master"
set :deploy_via, :remote_cache