Skip to content

Instantly share code, notes, and snippets.

View bran921007's full-sized avatar
🏠
Working from home

Fran Perez bran921007

🏠
Working from home
View GitHub Profile
@bran921007
bran921007 / gist:4d706175a5459433272eda2143c0f50c
Created January 30, 2022 20:32
Generate QR Code with just 1 line of JavaScript code
<div id="qrcode"></div>
<script type="text/javascript"> // Change String here↓
new QRCode(document.getElementById( "qrcode"), "https://blog.suhailkakar.com");
</script>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js">
</script>
@bran921007
bran921007 / settings.json
Created January 23, 2022 00:46 — forked from aschmelyun/settings.json
VS Code Settings
{
"editor.codeLens": false,
"workbench.colorTheme": "Atom One Dark",
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
},
"editor.selectionHighlight": false,
"editor.highlightActiveIndentGuide": false,
@bran921007
bran921007 / gist:c71b6fc18e679a63e8f7bd34da94aaae
Created January 5, 2022 02:59
add conditional aggregate in mysql
Course::query()
->select('courses.*')
->addSelect([
"lessons count' => Lesson::query ()
->select (DB: : raw( 'COUNT (lessons. id) '))
->whereColumn ('lessons.course id','courses. id'),
'total_length' => Lesson::query()
->select (DB: : raw ('SUM (lessons. video_length) '))
->whereColumn('lessons. course_id', 'courses.id') ,
])
@bran921007
bran921007 / minMaxSum.php
Created January 4, 2022 18:20
get min and max sumatories in 4 of 5 elements in array
function miniMaxSum($arr) {
// Write your code here
$sumatories = [];
foreach($arr as $index => $value){
$tempArr = $arr;
unset($tempArr[$index]);
$sumatories[] = array_sum($tempArr);
}
@bran921007
bran921007 / stairscase.php
Created January 4, 2022 18:17
Strairs Case code challenge (get reverse stairs * with same height
function staircase($n) {
$staircase = 0;
foreach(range(1,$n) as $i){
echo str_repeat(' ',$n-1).str_repeat('#',$i).PHP_EOL;
$n--;
}
}
staircase(6);
@bran921007
bran921007 / gist:5156ea5d0d07ab1b3b8835707ba5b345
Created December 6, 2021 19:23
path file into UploadedFile class object
/**
* Create an UploadedFile object from absolute path
*
* @static
* @param string $path
* @param bool $public default true
* @return object(Symfony\Component\HttpFoundation\File\UploadedFile)
*/
private function pathToUploadedFile( $path, $public = true )
{
@bran921007
bran921007 / populateLookupTable.php
Created November 21, 2021 20:54
Exec raw SQL statements directly in Laravel
//https://twitter.com/aarondfrancis/status/1461390854598402048/photo/1
//you can use Laravel's Schema builder anywhere you want, not just in migrations!
//If you ever need to make a temp table to help you mass process data more quickly, it's a great solution.
public function populateLookupTable($countyId)
{
Schema::dropIfExists ('tmp gis_lookup'
Schema::create ('tmp_gis_lookup', function (Blueprint $table) {
$table->temporary();
@bran921007
bran921007 / gist:274b0e05b767be801e26a4c415e2ba8e
Created November 21, 2021 01:16
use architecture x86_64 Intel - in Macbook M1 - Rosetta 2 (Apple Silicon)
arch -x86_64 zsh
@bran921007
bran921007 / gist:8dfc1bc12d22d7c769b19966a6f4ea11
Created November 21, 2021 01:14
disable Gatekeeper on M1 MacBook Monterey
sudo spctl --global-enable
@bran921007
bran921007 / gist:bbb27d4e463cee096995c3f57ea39434
Created August 3, 2021 00:16
Order by custom algorithms - Laravel PHP Eloquent
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Feature extends Model
{
public function comments()