Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
tegansnyder / array_2_csv.php
Created March 3, 2014 00:04
Write a associative array to a CSV file.
<?php
$arr = array();
$arr[0]['derp'] = 'hi';
$arr[0]['blerg'] = 'hey';
produceCSV('data.csv', $arr);
function produceCSV($file_name, $arr) {
var that = this;
this.myForm = this.FormBuilder.group({
username: ["", this.Validators.required],
password: ["", this.Validators.required],
bio: ["", this.Validators.required],
});
this.create = function() {
console.log("VALUES", that.myForm.valid, that.myForm.value);
@tpunt
tpunt / doc.md
Last active October 8, 2018 06:57
PHP 7.2 Migration Guide ToDo's

Incompatibilities:

  • Session:
    • Removed register_globals related code and "!" can be used as $_SESSION key name.
    • Session is made to manage session status correctly and prevents invalid operations. Only inappropriate codes are affected by this change. If you have problems with this, it means you have problem in your code.
      • Functions are made to set or return correct session status. session_start(), session_status(), session_regenerate_id()
  • Functions are made to return bool from null. These functions have void parameter
@mynameispj
mynameispj / orientationChange.js
Last active September 3, 2020 19:39
jQuery event that fires when the orientation (portrait, landscape) of a mobile device changes
window.addEventListener("orientationchange", function() {
alert(window.orientation);
//do whatever you want on orientation change here
}, false);
Установить Docker CE и docker-compose на систему, если у вас MacOS или Windows
вы можете скачать установщик с офф. сайта
https://www.docker.com/get-started
Если же у вас Linux проводим установку как указано здесь:
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce
Далее устанавливаем docker-compose
https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-16-04
@prappo
prappo / .env
Created August 21, 2016 10:22
env file for Laravel postgresql database
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:hyHUpukUUigKeEsxpGeTW4UZ+Lg+WAWxcc4/BjlgNtE=
APP_URL=http://localhost
DB_CONNECTION=pgsql
DB_HOST=hostname
DB_PORT=5432
DB_DATABASE=Your database name
DB_USERNAME=Your database username
// http://stackoverflow.com/a/5727346/3774582
// Parse CRON frequency
// Break it down like James Brown
function parse_crontab($time, $crontab) {
// Get current minute, hour, day, month, weekday
$time = explode(' ', date('i G j n w', strtotime($time)));
// Split crontab by space
$crontab = explode(' ', $crontab);
// Foreach part of crontab
foreach ($crontab as $k => &$v) {
@jarvys
jarvys / run-multiple-redis-instances.md
Last active September 27, 2022 13:02
run multiple redis instances on the same server for centos
  • create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf
  • edit /etc/redis-xxx.conf, illustrated as below
...
@goranprijic
goranprijic / BaseModel.php
Created December 17, 2014 10:12
Check if table is already joined in Laravel Query Builder
<?php
class BaseModel extends Eloquent {
public static function isJoined($query, $table)
{
$joins = $query->getQuery()->joins;
if($joins == null) {
return false;
}
'use strict';
var gulp = require('gulp'),
watch = require('gulp-watch'),
prefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
rigger = require('gulp-rigger'),
cssmin = require('gulp-minify-css'),