Skip to content

Instantly share code, notes, and snippets.

View rosswarren's full-sized avatar
⌨️
typing

Ross Warren rosswarren

⌨️
typing
View GitHub Profile
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.CallExpression)
.filter(x => x.node.callee.object && x.node.callee.object.name === "assert")
.filter(x => x.node.callee.property && x.node.callee.property.name === "isFalse")
.filter(x => x.node.arguments.length > 0 && x.node.arguments[0].property && x.node.arguments[0].property.name === "called")
.forEach(path => {
@rosswarren
rosswarren / assert-codemod.js
Last active February 9, 2022 12:10
Chai expect to assert
'use strict';
function buildExpectStatement(expectStatement) {
const properties = expectStatement.split('.').reverse();
const expectCall = {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'expect'
@rosswarren
rosswarren / gist:4e3b71f15638d60605b6
Created June 5, 2015 09:57
Polaris Radial Gradient
background: rgb(255,255,255); /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPHJhZGlhbEdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iNzUlIj4KICAgIDxzdG9wIG9mZnNldD0iMzAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTYlIiBzdG9wLWNvbG9yPSIjZTVlNWVhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTYlIiBzdG9wLWNvbG9yPSIjZTVlNWVhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNzElIiBzdG9wLWNvbG9yPSIjYzljN2QxIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L3JhZGlhbEdyYWRpZW50PgogIDxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,
@rosswarren
rosswarren / JersyConfig.java
Last active August 29, 2015 14:06
ParamBasedParameterNameProvider for use in Jersey to get nice output when you use Bean Validations
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(ValidationConfigurationContextResolver.class);
}
}
@rosswarren
rosswarren / hello.rb
Created December 8, 2011 22:55
Object orientated Ruby Hello World
class HelloWorld
def initialize(name)
@name = name.capitalize
end
def sayHi
puts "Hello #{@name}!"
end
end
hello = HelloWorld.new("Github and Octopress!")
@rosswarren
rosswarren / proxy
Created November 23, 2011 23:02
Proxy Apache to Thin with SSL
</Proxy *>
AddDefaultCharset off
Order deny,allow
Deny from all
Allow from localhost
</Proxy>
@rosswarren
rosswarren / adialog.java
Created September 26, 2011 22:17 — forked from benjgorman/adialog.java
Android Dialog
final Button button6 = (Button) findViewById(R.id.btn_addRAddress);
button6.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Context mContext = v.getContext();
final Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.add_address);
dialog.setTitle("Add Address");
@rosswarren
rosswarren / AIBat.cs
Created March 16, 2011 22:38
The Artificially Intelligent Pong Bat
namespace Pong
{
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
public class AIBat : Bat
{
public AIBat(ContentManager content, Vector2 screenSize, bool side) : base(content, screenSize, side)
{
screenWidth = 800;
screenHeight = 600;
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
graphics.ApplyChanges();
GraphicsDevice.Clear(Color.CornflowerBlue);