Skip to content

Instantly share code, notes, and snippets.

View samsamm777's full-sized avatar

Sam Hudson samsamm777

View GitHub Profile
@samsamm777
samsamm777 / gist:7230159
Last active April 26, 2024 13:24
PHP set private property value using reflection. This allows you to set a private property value from outside the object, great for PHPUnit testing.
<?php
$a = new A();
$reflection = new \ReflectionClass($a);
$property = $reflection->getProperty('privateProperty');
$property->setAccessible(true);
$property->setValue($a, 'new-value');
echo $a->getPrivateProperty();
//outputs:
@samsamm777
samsamm777 / test.php
Created February 13, 2015 10:30
Example use of predis transactions to do check and set conditional updates. Running this example from multiple threads will maintain a consistent increment value
// Our redis client
$redis = $this->getContainer()->get("redis_client");
// Set the key
$key = 'my_key';
// predis transaction options
$options = array(
'cas' => true, // Initialize with support for CAS operations
'watch' => $key, // Key that needs to be WATCHed to detect changes
// BAD
searchResults: [
{name: 'New Noise',
artist: 'The Refused',
album: 'The Shape of Punk to Come'},
{name: 'Hands Down',
artist: 'Dashboard Confessional',
album: 'A Mark, a Mission, a Brand, a Scar'},
{name: 'name',
artist: 'artist',
import {TestBed} from '@angular/core/testing';
import {ArtworkService} from './artwork.service';
import * as path from 'path';
import {remote} from 'electron';
//import * as child from 'child_process';
import * as ChildProcess from 'child_process';
//import {spawn} from 'child_process';
import {shell} from 'electron';
//import * as et from 'electron';
import { ApplicationService, NotificationService, WorkspaceService } from '../../core';
import { Component, OnInit } from '@angular/core';
import { FlixBaseComponent } from '../base/flixbase.component';
import { remote } from 'electron';
@Component({
selector: 'flx-main',
templateUrl: './main.component.html',
styleUrls: ['./main.component.scss']
})
@samsamm777
samsamm777 / map.go
Last active September 26, 2017 16:02
package main
import (
"fmt"
"math/rand"
"strconv"
"time"
)
type Vector2D struct {
#!/bin/bash
echo "try to connect..."
ssh -R 8080:127.0.0.1:80 filth@danderson.ddns.net
tail -f /tmp/dummy_file
using UnityEngine;
using System.Collections;
public class Looky : MonoBehaviour
{
/**
* The target we will snap to.
*/
public Transform target;
Scenario: Ensure we can successfully create panel revisions and prove the panel
revision number increments properly.
Given I send a header-signed "POST" request to "/show/$showId/panel" with content type "application/json" with body:
"""
{
"title": "my show",
"description": "this is a test show"
}
"""
And the response code should be 201
using UnityEngine;
using System.Collections;
public class Looky : MonoBehaviour
{
/**
* The target for where we want to face
*/
public Transform target;