Skip to content

Instantly share code, notes, and snippets.

View bishoyAtif's full-sized avatar

BishoyAtif bishoyAtif

View GitHub Profile
@bishoyAtif
bishoyAtif / array-slice-passing.go
Created January 20, 2024 11:51
Passing Array VS Slice to methods
package main
import "fmt"
func main() {
myArr := [10]int{}
mySlice := []int{1, 2}
fmt.Printf("Array location in the main method = %d\n", &myArr[0])
arrayPrintStartingLocation(myArr)
@bishoyAtif
bishoyAtif / cloudSettings
Last active February 5, 2020 20:08
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-05T20:11:34.134Z","extensionVersion":"v3.4.3"}
@bishoyAtif
bishoyAtif / primitive-reference-types-javascript.md
Last active March 5, 2019 16:08 — forked from branneman/primitive-reference-types-javascript.md
Primitive Types & Reference Types in JavaScript

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.

Facts

  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.16/datatables.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css">
<title>Posts</title>
</head>
<body>
<div class="container" style="margin-top: 50px">
{ data: "actions",
render: function(data){
return htmlDecode(data);
}
}
function htmlDecode(data){
var txt=document.createElement('textarea');
txt.innerHTML=data;
return txt.value
}
<?php
->addColumn('actions', function($row){
$editUrl = route('posts.edit', $row->id);
$deleteUrl = route('posts.destroy', $row->id);
return view('_formActions', compact('editUrl', 'deleteUrl'));
})
<form action="{!! $deleteUrl !!}" method="POST">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{!! $editUrl !!}" class="btn btn-primary" role="button" aria-pressed="true">Edit</a>
{ data: null,
render: function(data){
var edit_button = '<a href="' + data.edit_url + '" class="btn btn-primary" role="button" aria-pressed="true">Edit</a>';
var delete_button = '<form action="' + data.delete_url + '" method="POST"><input type="hidden" name="_method" value="delete">{{csrf_field()}}<button type="submit" class="btn btn-danger">Delete</button>';
return edit_button + delete_button;
}
},
<?php
->addColumn('edit_url', function($row){
return route('posts.edit', $row->id);
})
->addColumn('delete_url', function($row){
return route('posts.destroy', $row->id);
})