Skip to content

Instantly share code, notes, and snippets.

@j4k
j4k / error.txt
Created February 25, 2019 10:29
terraform error
* module.infra-production.module.jpmain-cloudsql-rr-ha.output.replica_instance_sql_ipv4s: Resource 'google_sql_database_instance.new_instance_sql_replica' does not have attribute 'ip_address.0.ip_address' for variable 'google_sql_database_instance.new_instance_sql_replica.*.ip_address.0.ip_address'
@j4k
j4k / httpd-vhosts.conf
Created April 2, 2016 14:01
Apache 2.4 Reverse Proxy to Nginx port 80 => 8080
<VirtualHost *:80>
ServerName something.app
ProxyPreserveHost On
ProxyRequests Off
RequestHeader unset Accept-Encoding
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
@j4k
j4k / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@j4k
j4k / gist:00460137a1ed3abbbb51
Created October 30, 2014 09:58
batch remote alter git remotes from base directory
#!/bin/bash
for gitdir in `find ./ -name .git`;
do
workdir=${gitdir%/*};
echo;
reponame=$(basename $(git --git-dir=$gitdir remote show -n origin | grep Fetch | cut -d: -f2-));
echo $reponame;
neworigin="git@[REPLACE_WITH_URL]/$reponame";
echo $neworigin;
// ========== PX to EM calculation
// It strips the unit of measure and returns it
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
// Converts "px" to "em" using the ($)em-base
@function convert-to-em($value) {
$value: strip-unit($value) / strip-unit($font-size) * 1em;
@if ($value == 0em) { $value: 0; } // Turn 0em into 0
// Fetch the Feed object
$jobsXML = simplexml_load_file('https://tsb-applications.advorto.com/candidate/vacancyfeed.aspx');
// Cache it as a JSON object
Cache::set('jobs', false, json_encode($jobsXML), false);
// Fetch the cached object
$jobs = Cache::get('jobs', false);
@j4k
j4k / gist:cb4b6bd86a8fa4bda4b6
Created July 13, 2014 17:42
Laravel UserController Test
<?php
use \Illuminate\Session\TokenMismatchException;
class UserControllerTest extends BaseControllerTestCase {
public function testShouldLogin()
{
$this->requestAction('GET', 'UserController@getLogin');
$this->assertRequestOk();
@j4k
j4k / gist:76b9b0efe8344be06369
Created July 12, 2014 19:33
Concrete 5 Captcha
$captcha = Loader::helper('validation/captcha');
echo $captcha->display();
echo $captcha->showInput();
if($captcha->check()){
// User passed, continue processing...
}
@j4k
j4k / c5formvalidate
Created July 12, 2014 19:31
Concrete 5 Form Validation Helper
$val = Loader::helper('validation/form');
$data = array(
'name' => 'Jane Doe',
'email' => '',
'website' => 'http://example.com',
'content' => 'Great Post!'
);
$val->setData($data);
@j4k
j4k / gist:9674753
Created March 20, 2014 21:55
radians in postgres
CREATE INDEX radians ON spaces USING gist (ll_to_earth(lng, lat))