Skip to content

Instantly share code, notes, and snippets.

/*
* Companion code for article at http://toddhayton.com/2018/08/01/scraping-with-puppeteer/
*
* Setup:
* $ mkdir scraper/
* $ cd scraper/
* $ npm init -y
* $ npm install puppeteer --save
*
* Usage:
@virolea
virolea / upload.js
Last active August 28, 2024 02:16
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@ar-android
ar-android / Download.php
Created July 7, 2017 07:13
Download file using guzzle
<?php
class Download {
public function download($url, $name, $extensions){
$path = __DIR__.'/download/' . $name . $extensions;
$file_path = fopen($path,'w');
$client = new \GuzzleHttp\Client();
$response = $client->get($url, ['save_to' => $file_path]);
return ['response_code'=>$response->getStatusCode(), 'name' => $name];
}
@javilobo8
javilobo8 / download-file.js
Last active September 2, 2024 03:58
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@jimmywarting
jimmywarting / readme.md
Last active September 19, 2024 08:23
Cors proxies
Exposed headers
Service SSL status Response Type Allowed methods Allowed headers
@vluzrmos
vluzrmos / paginate.php
Created July 20, 2016 14:31
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@gokulkrishh
gokulkrishh / media-query.css
Last active September 21, 2024 13:40
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@ainsofs
ainsofs / gist:2b80771a5582b7528d9e
Created April 16, 2015 01:50
Clear .gitignore cache
# remove specific file from git cache
git rm --cached filename
# remove all files from git cache
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@qstudio
qstudio / get_post_by_meta.php
Last active April 4, 2024 11:24
WordPress / Get Post by Meta Value
<?php
/**
* Get Post object by post_meta query
*
* @use $post = get_post_by_meta( array( meta_key = 'page_name', 'meta_value = 'contact' ) )
* @since 1.0.4
* @return Object WP post object
*/
function get_post_by_meta( $args = array() )
@BFTrick
BFTrick / install-wp.sh
Last active April 1, 2024 04:14
Download & Install WordPress via Curl
curl -O https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress site
rm latest.zip