Skip to content

Instantly share code, notes, and snippets.

public function add() {
Configure::write('debug', 2);
try {
if (!$this->checkKey()) {
throw new Exception('Empty key', 10016);
}
public function get_featured_deals() {
Configure::write('debug', 2);
$result = array('code' => 200, 'time' => time());
try {
if (empty($this->request->data['private_token'])) {
// private token not found
throw new Exception('Empty private token', 10002);
}
if (empty($this->request->data['categories'])) {
private function __get_id($qr_code) {
if (empty($qr_code)) {
return false;
}
$arrBarCode = explode(',', $qr_code);
if (empty($arrBarCode[1])) {
return false;
}
$beginning = substr($arrBarCode[1], 0, 16);
$end = substr($arrBarCode[1], -16);
@brunokruse
brunokruse / stirling approximation
Last active August 29, 2015 13:57
for grandpa
import math
# stirling approximation
def stirling(n):
return math.sqrt(2*math.pi*n)*(n/math.e)**n
def npr(n,r):
return (stirling(n)/stirling(n-r) if n>20 else
math.factorial(n)/math.factorial(n-r))
switch ($campaign['Campaign']['deal_type']) {
case 'lottery':
$enteredLotteryCount = $this->SpecialSaving->find('count', array(
'recursive' => -1,
'conditions' => array(
'private_token' => $private_token,
'campaign_id' => $campaign['Campaign']['id']
)
));
@brunokruse
brunokruse / count_redeemed
Created March 7, 2014 16:00
count redeemed debug
<?php
App::uses('AppModel', 'Model');
/**
* @property User $User
* @property Saving $Saving
* @property Scan $Scan
*/
class Campaign extends AppModel {
@brunokruse
brunokruse / batch_save
Created March 6, 2014 19:33
loops through WP image posts and updates their thumbnail
<?php
/**
* Plugin Name: Batch update posts
* Description: Save all posts to update thumbnails
* Version: 1.0
* Author: BK + Potion
* License: GPL2
*/
function batch_update() {
public function deal_datas($private_token, $campaign_ids) {
$campaigns = $this->find('all', array(
'fields' => array(
'User.country_id',
'User.street',
'User.zipcode',
'User.location',
'User.phone',
'Campaign.id',
void loadCSV() {
string sFileContents = "";
using (StreamReader oStreamReader = new StreamReader(File.OpenRead("Test.csv")))
{
sFileContents = oStreamReader.ReadToEnd();
}
List<string[]> oCsvList = new List<string[]>();
IEnumerator SpawnEnemies ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
for(int i = 0; i < birdCount; i++)
{
Vector3 spawnPosition = new Vector3 (spawnLocation.x,spawnLocation.y, spawnLocation.z - 5.0f);
Quaternion spawnRotation = Quaternion.identity;