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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
defmodule AuctionTest do | |
use ExUnit.Case | |
alias Auction.{Item, Repo} | |
doctest Auction | |
setup do | |
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo) | |
end | |
describe "list_items/0" do |
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
export default (list, fn) => { | |
return list.reduce((acc, value) => { | |
return { ...acc, [fn(value)]: value } | |
}, {}) | |
} | |
// const cars = [ | |
// { brand: 'bmw', model: 'm3', year: 2013 }, | |
// { brand: 'opel', model: 'astra', year: 2014 }, | |
// { brand: 'honda', model: 'accent', year: 2014 }, |
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
import React, { Component, PropTypes, } from 'react'; | |
import { reduxForm, Field } from 'redux-form'; | |
import Dropzone from 'react-dropzone'; | |
const FILE_FIELD_NAME = 'files'; | |
const renderDropzoneInput = (field) => { | |
const files = field.input.value; | |
return ( |
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
function declOfNum(titles){ | |
var cases = [2, 0, 1, 1, 1, 2]; | |
return function(number){ | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
}; |
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
$db['db_host'] = 'localhost'; | |
$db['db_user'] = 'root'; | |
$db['db_password'] = ''; | |
$db['db_name'] = 'cms'; | |
foreach($db as $key => $value){ | |
define(strtoupper($key), $value); | |
}; | |
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
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
SELECT | |
REPLACE(COLUMN_TYPE, 'set', '') `values` FROM information_schema.COLUMNS WHERE | |
TABLE_SCHEMA = 'vote-app' -- your database name here | |
AND | |
TABLE_NAME = 'districts' -- your table name here | |
AND | |
COLUMN_NAME = 'district' -- your column name"; |
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
//image upload | |
$target_dir = "img/"; | |
$target_file = $target_dir . basename($_FILES["image_pit"]["name"]); | |
$uploadOk = 1; | |
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); | |
// Check if image file is a actual image or fake image | |
if (isset($_FILES['image_pit'])) { | |
$check = getimagesize($_FILES["image_pit"]["tmp_name"]); | |
echo $_FILES["image_pit"]["tmp_name"]; | |
if($check !== false) { |
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
function delete_user() { | |
global $connection; | |
$id = $_POST['id']; | |
echo $id; | |
if (!$connection) { | |
die ('connection failed'); | |
}; | |
$query = "DELETE FROM users "; | |
$query .= "WHERE id = $id "; |
NewerOlder