This file contains 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
framework 'Foundation' | |
class String | |
def language | |
CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0, self.size)) | |
end | |
end | |
puts "Happy new year!".language | |
# => "en" | |
puts "С новым годом!".language |
This file contains 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
# 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 |
This file contains 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
// 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 = { |
This file contains 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
// Если 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=/'; | |
} |
This file contains 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
/** | |
* 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; |
This file contains 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
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'); |
This file contains 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
# 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 |
This file contains 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
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 |
This file contains 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
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 |