Skip to content

Instantly share code, notes, and snippets.

@MadaraUchiha
MadaraUchiha / Form.php
Created March 5, 2014 10:44
Form object for validation
<?php
Form {
private $vars = [];
private $validators = [];
private $errors = [];
private $validatedVars = [];
/**
@MadaraUchiha
MadaraUchiha / answer.md
Created May 19, 2014 14:31
How to pass variables from PHP to JavaScript

There are actually several approaches to do this. Some require more overhead than others, and some are considered better than others.

Ordered by "Better Practice":

  1. Use AJAX to get the data you need from the server.
  2. Echo the data into the page somewhere, and use JavaScript to get the information from the DOM.
  3. Echo the data directly to JavaScript.

In this post, we'll examine each of the above methods, and see the pros and cons of each, as well as how to implement them.

@MadaraUchiha
MadaraUchiha / dabblet.css
Created June 10, 2014 14:07
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body {
font-family: Arial;
}
h1, #container {
text-align: center;
@MadaraUchiha
MadaraUchiha / master.php
Created July 1, 2014 14:42
Global Example
<?php
$variable = "This will be global!";
include "slave.php";
@MadaraUchiha
MadaraUchiha / log_oop_example.php
Last active August 29, 2015 14:04
PHP OOP Logger example
<?php
interface ICanLog {
public function writeLine($line);
}
class FileLogger implements ICanLog { //Now I have to implement writeLine!
private $where;
public function __construct($where) {
$this->file = $where;
@MadaraUchiha
MadaraUchiha / main.js
Created September 11, 2014 21:18
My current version of the main JS file. Still in development.
/**
* Created by dor.t on 8/24/2014.
*/
var express = require("express"),
path = require('path'),
Promise = require('bluebird'),
mongo = require('mongodb').MongoClient,
mongoConn,
app = express();
@MadaraUchiha
MadaraUchiha / ajaxformSubmit.js
Last active August 29, 2015 14:08
ajaxFormSubmit.js
/**
* Takes a form node and sends it over AJAX.
* @param {HTMLFormElement} form - Form node to send
* @param {function} callback - Function to handle onload.
* this variable will be bound correctly.
*/
function ajaxFormSubmit (form, callback) {
var url = form.action,
xhr = new XMLHttpRequest();
@MadaraUchiha
MadaraUchiha / conclusions.md
Last active August 29, 2015 14:12
JavaScript room meeting

Meeting is adjourned. Following are the conclusions to the meeting:

  1. Help vampire treatment status.
  2. Users with low reputation or QA ratio should get a more targetted message
  3. Users who are being obvious help vampires are to be kicked
  4. If another regular is helping a help vampire, please inform them via a separate room
  5. Kicking policy
  6. Announcing kicks is no longer mandatory and should probably be discouraged - opening a room with the user is not obligatory but is nice, a meta post was opened about prompting other room owners but not general users about kicks.
  7. Lemon's 12 days of Christmas
  8. Was awesome
> $ sudo apt-get update [±master]
Ign http://il.archive.ubuntu.com utopic InRelease
Ign http://il.archive.ubuntu.com utopic-updates InRelease
Ign http://il.archive.ubuntu.com utopic-backports InRelease
Hit http://il.archive.ubuntu.com utopic Release.gpg
Hit http://il.archive.ubuntu.com utopic-updates Release.gpg
Hit http://il.archive.ubuntu.com utopic-backports Release.gpg