This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Optimize image image | |
| * | |
| * https://developers.google.com/speed/docs/insights/OptimizeImages | |
| * -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB | |
| * | |
| * @access public | |
| * @param string $filePath Path of the file | |
| * @return string Raw image result from the process | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Model\Table\Behavior; | |
| trait UpdateCounterCacheTrait { | |
| public function cleanupBelongsToMany($return_count = null) { | |
| if($return_count) { | |
| return $count; | |
| } | |
| return $this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project name="name-of-project" default="build-parallel"> | |
| <target name="build" | |
| depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpunit,phpcb"/> | |
| <target name="build-parallel" | |
| depends="prepare,lint,tools-parallel,phpunit,phpcb"/> | |
| <target name="tools-parallel" description="Run tools in parallel"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Check if a given ip is in a network | |
| * @param string $ip IP to check in IPV4 format eg. 127.0.0.1 | |
| * @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed | |
| * @return boolean true if the ip is in this range / false if not. | |
| */ | |
| function ip_in_range( $ip, $range ) { | |
| if ( strpos( $range, '/' ) == false ) { | |
| $range .= '/32'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Turn on Expires and set default to 0 | |
| ExpiresActive On | |
| ExpiresDefault A0 | |
| # Set up caching on media files for 1 year (forever?) | |
| <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> | |
| ExpiresDefault A29030400 | |
| Header append Cache-Control "public" | |
| </FilesMatch> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Note that I wrote this in java in Processing - paste this GIST into processing to see it in action. | |
| // It is not the most elegant thing ever but it does deal with end caps and ribbon loops and the like. | |
| // If you port this over to say objective-c / opengl / c etc - you may need to deal with polygon direction | |
| // here is a snapshot of it running : http://www.flickr.com/photos/anselmhook/6507471719/in/photostream | |
| int nvertices = 0; | |
| float[] vertexpool = new float[3000]; | |
| float x1,x2,y1,y2; | |
| void intersect(int kind, float x0, float y0, float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example program | |
| #include <type_traits> | |
| #include <stdint.h> | |
| #include <vector> | |
| #include <cstddef> | |
| #include <iostream> | |
| enum class InputActionType : uint8_t | |
| { | |
| Nothing, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Entity/Rail.hpp> | |
| #include <Entity/RailSignalBase.hpp> | |
| #include <Rail/RailBlock.hpp> | |
| #include <Rail/RailPath.hpp> | |
| #include <Rail/TrainPathFinder.hpp> | |
| #include <Rail/RailSegment.hpp> | |
| #include <Rail/RailUtil.hpp> | |
| #include <Rail/Train.hpp> | |
| #include <Log.hpp> |