Skip to content

Instantly share code, notes, and snippets.

@kevinquinnyo
kevinquinnyo / fuck.html.erb
Created June 20, 2011 03:02
this doesn't work
#pages_controller
def home
@places = Place.all
@stories = Story.all
...
@kevinquinnyo
kevinquinnyo / badproc.py
Created August 14, 2011 21:31
isolate time range from apache log file(s)
#!/usr/bin/python
import sys
import re
import time
from datetime import timedelta, datetime
now = datetime.now()
d_format = '%d/%b/%Y:%H:%M'
try:
back_minutes = timedelta(minutes=int(sys.argv[2])) #no more trash var
raw_bad_process_time = now.strftime('%d/%b/%Y:') + sys.argv[1] #gets d/m/y
<?php
// more efficient way to do this than creating an array of all permutations indexed by each value and comparing to eachother?
$array = [ 'asdfasdfasdf_X', 'asdfasdfasdf_Y', '123412341234_X', 'asdfasdfasdf_Z', '123412341234_Y', 'dsfjiowefnilknml' ];
$permutations = [];
for($i=0; $i<count($array); $i++) {
$key = array_shift($array);
$permutations[$key] = $array;
/src/Controller/Api/V1/BandwidthGraphsController.php (line 52)
object(App\Model\Entity\BandwidthGraph) {
'new' => false,
'accessible' => [
'*' => true
],
'properties' => [
'id' => (int) 24,
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start='1420076062' \
--end='1420162462' \
--title='EDGE-AA.atl01 - Traffic - Te1/1' \
--rigid \
--base='1000' \
--height='120' \
--width='500' \
--alt-autoscale-max \
Dataset 1 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1.5,2]
95th percentile 1.5
Dataset 2 [200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,250,300]
95th percentile: 250
The sum of those Datasets' 95th's would be 251.5. This is "Stacked".
$array = [
'0' => [
'data' => [
'traffic_in' => [
'1',
'2',
'3',
'4'
],
'traffic_out' => [
@kevinquinnyo
kevinquinnyo / gist:96ff4130f882101e24d5
Last active August 29, 2015 14:22
BaseAuthenticate idea
<?php
abstract class BaseAuthenticate implements EventListenerInterface
{
// snip..
protected function _findUser($query, $username = null, $password = null)
{
$fields = $this->_config['fields'];
protected function _findUser($username, $password = null)
{
$userModel = $this->_config['userModel'];
list(, $model) = pluginSplit($userModel);
$fields = $this->_config['fields'];
$conditions = [$model . '.' . $fields['username'] => $username];
$scope = $this->_config['scope'];
if ($scope) {
def web(self):
self.states[self.webroot_base] = {
'file.directory': [
{'name': self.webroot_base}
{'mode': 750},
{'owner': 'root'},
{'group': 'root'}
]
}