Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Stanberry cranberyxl

View GitHub Profile
@cranberyxl
cranberyxl / git.md
Last active Apr 28, 2021
Useful git bash scripts
View git.md

List remote branches already merged to main

git fetch origin > /dev/null; git checkout origin/main; for branch in $(git branch -a --merged | grep remotes/origin | grep -v main | grep -v 'no branch'| sed -e 's/\s*remotes\///'); do echo "${branch:7}"; done; git checkout main

Delete remote branches already merged to main

git fetch origin > /dev/null; git checkout origin/main; for branch in $(git branch -a --merged | grep remotes/origin | grep -v main | grep -v 'no branch'| sed -e 's/\s*remotes\///'); do git push origin :${branch:7}"; done; git checkout main
@cranberyxl
cranberyxl / desinty-hubot-slack.md
Last active Nov 3, 2015
Destiny Hubot for Slack
View desinty-hubot-slack.md

Destiny Slack Hubot setup

  1. Follow the basic heroku/hubot instructions here: https://gist.github.com/trey/9690729
  2. Add "slack-destiny-bot": "cranberyxl/slack-destiny-bot#search_armory" to package.json to get my fork of the bot with armory search. These will probably make their way back to the original repo eventually.
  3. Go to https://{your-slack-name}.slack.com/services/new/hubot to setup a new hubot integration
  4. Signup for a Bungie API key here: https://www.bungie.net/en/User/API
  5. Plugin the Bungie API key and the slack hubot token into heroku config
View gist:2722835
$ traceroute www.rr.com
traceroute to www.rr.com (24.28.199.168), 64 hops max, 52 byte packets
1 cpe-24-90-20-1 (24.90.20.1) 62.247 ms 28.031 ms 49.303 ms
2 gig-0-3-0-11-nycmnytf-rtr1.nyc.rr.com (24.29.151.193) 31.817 ms 36.352 ms 47.873 ms
3 bun106.nyquny91-rtr001.nyc.rr.com (184.152.112.99) 18.988 ms 29.686 ms 54.856 ms
4 bun6-nyquny91-rtr002.nyc.rr.com (24.29.148.254) 20.046 ms 23.258 ms 36.638 ms
5 ae-3-0.cr0.nyc20.tbone.rr.com (66.109.6.76) 51.327 ms 34.407 ms 14.770 ms
6 ae-0-0.cr0.nyc30.tbone.rr.com (66.109.6.26) 40.519 ms 81.203 ms 25.858 ms
7 ae-4-0.cr0.dca20.tbone.rr.com (66.109.6.28) 63.897 ms
66.109.9.30 (66.109.9.30) 47.622 ms 36.541 ms
@cranberyxl
cranberyxl / gist:2483417
Created Apr 24, 2012
How to download a github private tarball
View gist:2483417
curl -o {tag}.tgz -Lu "{githubuser}:{githubpassword}" https://github.com/{githubuser}/repo/tarball/{tag}
View gist:841505
<?php
class CachedClassMetadata extends ClassMetadata
{
private $filemtime;
public function setFilemtime($filemtime)
{
$this->filemtime = $filemtime;
}
@cranberyxl
cranberyxl / gist:830331
Created Feb 16, 2011
Use sessions across client requests
View gist:830331
<?php
class YourTestKernel extends \yourKernel
{
protected $session;
protected function initializeContainer()
{
parent::initializeContainer();
View gist:815072
<?php
public function testFoo()
{
$order = new Order();
$order->setBillingAddress($this->createAddress('billing'));
$order->setBillingAddress($this->createAddress('shipping'));
}
View php.rb
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.4.tar.gz/from/this/mirror'
homepage 'http://php.net/'
View ValidValidator1.php
<?php
namespace Symfony\Component\Validator\Constraints;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
View gist:492779
<?php
$filename = "/Andy.jpg";
$min = 800;
list($width, $height) = getimagesize($filename);
$source = imagecreatefromjpeg($filename);
$max = max($height, $width);
if ($min != null && $min > $max) {