Skip to content

Instantly share code, notes, and snippets.

View cholnhial's full-sized avatar

Chol Nhial cholnhial

View GitHub Profile
printf "Downloading Node 10...\n"
wget "https://nodejs.org/download/release/latest-v10.x/node-v10.24.0-linux-x64.tar.gz" -O /tmp/node10.tar.gz &> /dev/null
printf "Extracting Node 10...\n"
mkdir ~/.software
tar -xf /tmp/node10.tar.gz -C ~/.software &> /dev/null
printf "Configuring SHELL...\n"
if test -f ~/.bashrc; then
printf "Found bash configuring bash...\n"
echo 'export NODEJS_HOME=~/.software/node-v10.24.0-linux-x64' >> ~/.bashrc
echo 'export PATH=$NODEJS_HOME/bin:$PATH' >> ~/.bashrc
@cholnhial
cholnhial / gist:1f87ac1913e787eb0e6c
Created June 27, 2015 11:40
Bootstrap button with link CakePHP 2.0
echo $this->Html->link(
'Edit Post',
array(
'action' => 'edit',
'class' => 'btn btn-primary btn-md'
)
);
public function stock($id = null)
{
$fabric = $this->Fabrics->get($id, ['contain' => ['FabricColours']]);
if($this->request->is('post'))
{
$list = $this->Fabrics->FabricColours->find('all')->where(['fabric_id' => $id])->toArray();
$fabricColours = $this->Fabrics->patchEntities($list, $this->request->data('data'));
$data = $this->request->data['data'];
$countOf = count($fabricColours);
@cholnhial
cholnhial / PatchEntities error
Created June 16, 2015 08:14
PatchEntities only patches one entity in the list
{
/*#1 This is the data being used to patch,it's from $this->requests->data['data'] */
"data": [
{
"created": "6\/10\/15, 6:11 AM",
"updated": "",
"is_disabled": "0",
"fabric_colour_id": "107",
"name": "Athena",
$client = $this->Clients->get($id, ['contain' => ['Contacts', 'Contacts.ContactTitles', 'Contacts.States' => function($q) {
return $q
->select(['abbreviation']);
}, 'Contacts.Countries' => function($q)
{
return $q
->select(['name']);
}], 'joinType' => 'LEFT']);
echo count($client->contacts);
@cholnhial
cholnhial / gist:c93a6a89f4286b491025
Created May 21, 2015 05:42
Form not return list of Ids
DATA RETURN
------------
contact_types":[{"contact_type_id":1,"name":"Rarewear","created":"2015-05-21T04:04:29+0000","updated":null,"is_disabled":0}]}]}
FORM INPUT
------------
<?= $this->Form->input('contacts.0.contact_types._ids', ['label' => 'Associated Types', 'type' => 'select', 'multiple' => true, 'options' => $contact_types]) ?>
@cholnhial
cholnhial / custom login error message element
Created May 21, 2015 01:22
Modifying auth error message CakePHP 3.0
-- Templates/Element/Flash/login-error.ctp:
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<?= h($message) ?>
</div>
-- Templates/Users/login.ctp:
/* Put where you want to display the error messages */