This file contains hidden or 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 | |
namespace Application\Bundle\DefaultBundle\Entity; | |
use Symfony\Component\Validator\Constraints as Assert; | |
use Symfony\Component\HttpFoundation\File\UploadedFile; | |
use Symfony\Component\Security\Core\User\UserInterface; | |
use Doctrine\ORM\Mapping as ORM; |
This file contains hidden or 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 | |
protected function getSignature(array $params) | |
{ | |
ksort($params, SORT_STRING); | |
$str = ''; | |
foreach ($params as $key => $value) { | |
$str .= sprintf('%s=%s', $key, $value); | |
} |
This file contains hidden or 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
File srcFile = new File("/var/www/afishapoisk/public/uploads/images/events/big/new.jpg"); | |
File dstfile = new File("/var/www/afishapoisk/public/uploads/images/events/big/super.jpg"); | |
try { | |
FileOutputStream dstFos = new FileOutputStream(dstfile); | |
FileInputStream srcFos = new FileInputStream(srcFile); | |
byte[] buffer = new byte[256]; | |
int bytesRead; | |
do { |
This file contains hidden or 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
PreparedStatement pstmt = conn.prepareStatement("update blob_table set blob = ? where id = ?"); | |
File blob = new File("/path/to/picture.png"); | |
FileInputStream in = new FileInputStream(blob); | |
// the cast to int is necessary because with JDBC 4 there is | |
// also a version of this method with a (int, long) | |
// but that is not implemented by Oracle | |
pstmt.setBinaryStream(1, in, (int)blob.length()); | |
pstmt.setInt(2, 42); // set the PK value |
This file contains hidden or 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 | |
header('Content-Type: text/html; charset=utf-8'); | |
$s = file_get_contents('http://bananadream-monkey:8983/solr/select/?q=%D0%BF%D1%83%D1%88%D0%BA%D0%B8%D0%BD%0D%0A&version=2.2&start=0&rows=10&indent=on'); | |
$xml = simplexml_load_string($s); | |
$doc = $xml->result->doc[0]; | |
echo $doc->str[0]->attributes()->name; |
This file contains hidden or 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 | |
if (!empty($_GET['test'])) { | |
if (!empty($_SESSION)) { | |
foreach ($_SESSION as $name => $value) { | |
echo $name . '<br />'; | |
} | |
} | |
foreach ($_COOKIE as $name => $value) { | |
echo $name . '<br />'; |
This file contains hidden or 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 | |
$subject = <<<EOF | |
<style type="text/css"> | |
p { | |
font-size: 100500px; | |
} | |
</style> | |
some text |
This file contains hidden or 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
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller | |
// fixes from Paul Irish and Tino Zijdel | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; | |
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { |
This file contains hidden or 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 palindrome?(str) | |
str.downcase.gsub(/\W/, '') == str.downcase.gsub(/\W/, '').reverse | |
end | |
def count_words(str) | |
words = {} | |
str.downcase.split(/\W+/).each do |word| | |
words[word] = words.include?(word) ? words[word] + 1 : words[word] = 1 | |
end | |
words |
This file contains hidden or 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 rps_game_winner(game) | |
raise WrongNumberOfPlayersError unless game.length == 2 | |
2.times do |i| | |
raise NoSuchStrategyError unless ['P', 'S', 'R'].include? game[i][1].upcase | |
end | |
first = game[0][1].upcase | |
second = game[1][1].upcase | |
if first == 'P' |
OlderNewer