Skip to content

Instantly share code, notes, and snippets.

find = lambda number, max: len([n for n in (a/b for a,b in (((a*b),(a+b)) for a in range(1,max) for b in range(1, max)) if a != 0 or b != 0) if n == number])
print(find(7, 1000))
@tugrul
tugrul / LastThread.php
Created December 21, 2018 19:48
doctrine result proxy entity
<?php
namespace ForumBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class LastThread
* @package ForumBundle\Entity
*/
@tugrul
tugrul / agar.io.js
Created May 19, 2018 13:28
agar.io gamepad
(function(){
const canvas = document.getElementById('canvas');
let split = false;
let eject = false;
function loop() {
const width = window.innerWidth;
const height = window.innerHeight;
@tugrul
tugrul / slither.io.js
Created May 19, 2018 13:27
slither io gamepad
(function(){
let localGsc = 1;
function loop() {
const gamepad = navigator.getGamepads()[0];
if (!gamepad) {
console.log('gamepad not found');
@tugrul
tugrul / s3-archive.js
Created March 5, 2018 15:09
archive.org S3 like storage using Node.JS AWS API
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
endpoint: 'http://s3.us.archive.org',
accessKeyId: 'yourkeyid', // set your access key id
secretAccessKey: 'youraccesskey', // set your access key
signatureVersion: 'v2',
s3ForcePathStyle: true
});
@tugrul
tugrul / payment.php
Last active January 11, 2018 12:09
Self Declared Unique ID
<?php
class Payment
{
public $id;
public $posId;
public $amount;
public $currency;
public function getOrderId()
@tugrul
tugrul / TurkishCharacter.java
Last active January 10, 2016 11:58
NetBeans XDebug breakpoint_set Problem
package tugrul;
import java.nio.charset.Charset;
import java.util.Locale;
public class TurkishCharacter {
public static void main(String[] args) {
Locale.setDefault(Locale.ENGLISH);
@tugrul
tugrul / arrayobject.php
Created June 17, 2015 15:52
PHP BUG [SPL]: __get method is not calling
<?php
class MyArrayObject extends \ArrayObject
{
public function offsetGet($index)
{
if (!parent::offsetExists($index)) {
parent::offsetSet($index, new MyArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS));
}
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 5s;
.first_byte_timeout = 30s;
.between_bytes_timeout = 60s;
}
backend nodejs {
.host = "127.0.0.1";
@tugrul
tugrul / crypto.js
Last active December 12, 2015 09:19
var key = 'secretsecretsecretsecretsecretse';
var encrypted = 'msPH3nRKogXTrltyHHbPqQKznV8sk4FMoCAJjACPb6L+k4s0m2Jq1IkiOEH4rbml';
var crypto = require('crypto');
var decipher = crypto.createDecipher('aes-128-ecb', key);
var decrypted = decipher.update(encrypted, 'base64', 'utf8');
console.log('decrypted :', decrypted);