Skip to content

Instantly share code, notes, and snippets.

View samlovescoding's full-sized avatar
🔮
Building

Sampan Verma samlovescoding

🔮
Building
View GitHub Profile
.horizontal-container {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
.horizontal-container .scrollable-item {
flex: 0 0 auto;
}
@samlovescoding
samlovescoding / get_jpeg_size.php
Created October 6, 2019 01:28
getimagesize() will download the entire image before it checks for the requested information. This is extremely slow on large images that are accessed remotely. Since the width/height is in the first few bytes of the file, there is no need to download the entire file.
<?php
// Retrieve JPEG width and height without downloading/reading entire image.
function getjpegsize($img_loc) {
$handle = fopen($img_loc, "rb") or die("Invalid file stream.");
$new_block = NULL;
if(!feof($handle)) {
$new_block = fread($handle, 32);
$i = 0;
if($new_block[$i]=="\xFF" && $new_block[$i+1]=="\xD8" && $new_block[$i+2]=="\xFF" && $new_block[$i+3]=="\xE0") {
$i += 4;
@samlovescoding
samlovescoding / imagecreatefromsource.php
Created October 6, 2019 01:32
imagecreatefromsource creates an image by checking MIME type of a file
<?php
function imagecreatefromsource($source){
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg')
return imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
return imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
return imagecreatefrompng($source);
@samlovescoding
samlovescoding / AppServiceProvider.php
Created October 20, 2019 17:16
Laravel MySQL Default String Length
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
@samlovescoding
samlovescoding / .bashrc
Created October 29, 2019 21:43 — forked from Jatin-8898/.bashrc
My alias for Git Bash on Windows 10
# ----------------------
# Git Command Aliases
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'
alias gc='git commit -m'
alias gs='git status'
alias gr='git remote add origin'
alias gp='git push origin master'
@if ($errors->any())
@foreach ($errors->all() as $error)
<div class="alert alert-danger">
{{$error}}
</div>
@endforeach
@endif
@if(session('success'))
<div class="alert alert-success">
@samlovescoding
samlovescoding / yield_or_load_view.blade.php
Created November 28, 2019 16:47
Laravel Snippet - Blade @yield or load view
@yield('navbar', \View::make('dashboard.components.navbar'))
@samlovescoding
samlovescoding / ll_of_array.cpp
Created November 30, 2019 11:02
Linked List of Array
#include <iostream>
#define ARRMAX 100
using namespace std;
class LinkedList{
private:
struct node{
int info[ARRMAX];
node* next;
@samlovescoding
samlovescoding / pytmdb_expo.py
Created March 11, 2020 22:59
Python wrapper for tmdb API to transfer movies to Expo
# pip install tmdbsimple
# pip install requests
# python3 main.py
import tmdbsimple as tmdb
import json
import os
import requests
local = False
@samlovescoding
samlovescoding / index.html
Created April 18, 2020 17:02
UI Animating on Scroll: GSAP + ScrollMagic
<section>
<h1>Scroll down</h1>
</section>
<section class="sticky">
<blockquote>"You should totally subscribe to my channel now"<span></span></blockquote>
<img id="office" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2621168/office1.png">
<img id="building" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2621168/sky.jpg">
<div id="box"></div>
</section>