Skip to content

Instantly share code, notes, and snippets.

View mattraykowski's full-sized avatar

Matt Raykowski mattraykowski

View GitHub Profile
app.directive('draggableTask', function() {
return {
restrict: 'A',
replace: false,
transclude: false,
link: function(scope, element, attrs) {
attrs.$observe('taskContainer', function() {
console.log("task container: " + attrs.taskContainer);
element.draggable({
containment: '#' + attrs.taskContainer
@mattraykowski
mattraykowski / gist:5766165
Created June 12, 2013 15:12
The relevant CheckPlayerSpeed code.
// Check player speed
// only consider (x,y) motion for speed and position correction
if (master->PlayerInfos != NULL && master->PlayerInfos->CheckSpeed && CheckPlayerSpeed && fabs(movVector.x)+fabs(movVector.y) > maxDist)
{
double movNorm = sqr(movVector.x)+sqr(movVector.y); // already done if (entity != master) but here is a rare overspeed case
if (movNorm > sqr(maxDist))
{
if (VerboseSpeedAbuse)
{
@mattraykowski
mattraykowski / gist:8829887
Created February 5, 2014 18:18
Code Games
RubyWarrior - https://www.bloc.io/ruby-warrior/#/
JsWarrior - http://jswarrior.fusioncharts.com/
CheckiO - http://www.checkio.org/
Coode & Conquer - http://codeandconquer.co/
Code Combat - http://codecombat.com/
@mattraykowski
mattraykowski / Problem Description
Created April 21, 2014 18:02
Scoped Uniquess Validation throwing an error erroneously.
Problem:
So here, if I go into the console and run SuggestionVote.count I get 3 votes total by 2 other user ID's which are 2 and 3.
I log in as user ID 1, which has no suggestion votes. I click on the vote link and I get an error flashed:
Problem: ["User You can only vote once for a suggestion."]
I go back into the Rails console and do SuggestionVote.count and it now it shows 4.
So I'm getting the error message but it is creating the entry, but only the first time. If I manually go to the vote link again and recheck the Rails console I'm still at 4 votes - it is indeed not allowing multiple votes. Why it gives me the error but still creates the vote is a mystery.
@mattraykowski
mattraykowski / gist:55fb15638b268c797479
Created September 15, 2014 18:28
Testing safe_like out.
[7] pry(main)> person.last_name
=> "Raykowski"
[8] pry(main)> Person.safe_like(:last_name, "ray%")
Person Load (1.7ms) SELECT "people".* FROM "people" WHERE "people"."site_id" = 1 AND ("people"."last_name" ILIKE 'ray%')
=> [<1:Matt Raykowski>]
[9] pry(main)> Person.where(first_name: 'Matt')
Person Load (1.2ms) SELECT "people".* FROM "people" WHERE "people"."site_id" = 1 AND "people"."first_name" = 'Matt'
=> [<1:Matt Raykowski>]
[10] pry(main)> Person.where(first_name: 'Matt').safe_like(:last_name, 'ray%')
Person Load (1.1ms) SELECT "people".* FROM "people" WHERE "people"."site_id" = 1 AND "people"."first_name" = 'Matt' AND ("people"."last_name" ILIKE 'ray%')
@mattraykowski
mattraykowski / gist:b85252800e3efaf8d747
Last active August 29, 2015 14:06
arel-ish ishy Search.name!
def name!
return unless name
person = Person.arel_table
family = Family.arel_table
concat = Arel::Nodes::NamedFunction.new 'concat', [person[:first_name], ' ', person[:last_name]]
where(concat.matches(like(name)).or(
family[:name].matches(like(name)).or(
person[:first_name].matches(like(name.split.first, :after)).and(
person[:last_name].matches(like(name.split.last, :after))))))

Keybase proof

I hereby claim:

  • I am mattraykowski on github.
  • I am mattraykowski (https://keybase.io/mattraykowski) on keybase.
  • I have a public key whose fingerprint is AD34 FAD8 36C0 FD52 B842 7C05 5F39 F4F2 4D6D CB4C

To claim this, I am signing this object:

@mattraykowski
mattraykowski / main.js
Created November 6, 2014 16:50
Sample Interview Question Solution
var get_products_of_all_ints_except_at_index = function(arrayOfInts) {
var productArray = [];
arrayOfInts.forEach(function(element, index) {
var holderArray = arrayOfInts.slice(0);
holderArray.splice(index, 1);
var product = holderArray.reduce(function(previous, current) {
return previous*current;
});
@mattraykowski
mattraykowski / gist:94fa8b5f76512fbb299e
Created February 13, 2015 22:09
Shutting down a Scheduler on context destruction.
@Configuration
public class SpringConfiguration {
@Bean(destroyMethod="shutdown")
public Scheduler helloJob() {
JobDetail job = new JobDetail();
job.setName("dummyJobName");
job.setJobClass(HelloJob.class);
CronTrigger trigger = new CronTrigger();
trigger.setName("thirtySecondsTrigger");
@mattraykowski
mattraykowski / gist:164f22875aaba27f0ac0
Created February 19, 2015 15:11
Ryzom Core Studio Installer
==== Ryzom Core Studio ====
* '''Summary''': Ryzom Core Studio Installer
* '''Description''': Create a full end-to-end Windows installer for Ryzom Core Studio which walks the end user through setting up a complete Ryzom Core development platform. The installer should facilitate the configuration of a standalone development shard using a pre-built LAMP for Windows, configure the build pipeline to be able output a usable client, install and configure Studio, and integrate the build pipeline into Studio for easy build/preview clients.
* '''Technical Details''': The installer will need to be broken into several distinct bits of work: retrieving appropriate packages (server binaries, media database(s), build pipeline, Python and other third party requirements), installing dependent softwares (e.g. XAMPP, Python), pre-configuring the shard for localhost use (including configuration files and MySQL data), pre-configuring the build pipeline, a configuration wizard for collecting the data for configuring the dependen