Skip to content

Instantly share code, notes, and snippets.

@AleeRojas
AleeRojas / download-file.js
Created December 16, 2020 14:12 — forked from javilobo8/download-file.js
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);
@AleeRojas
AleeRojas / template-contact.php
Last active September 16, 2020 10:41 — forked from hansspiess/template-contact.php
Wordpress: Simple Contact Form
<?php
/*
Template Name: Kontakt
*/
?>
<?php /* other template code goes here... */ ?>
<?php
/*
* 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:
@AleeRojas
AleeRojas / media-query.css
Created December 15, 2018 19:05 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
<?php
// GET
$request = $client->get($url, array('Accept' => 'application/json'));
$response = $request->send();
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
// Error
}
@AleeRojas
AleeRojas / template-literals-2-for-each.js
Created April 24, 2018 12:40 — forked from wiledal/template-literals-2-for-each.js
Template Literals example: for each
/*
Template literals forEach example
Using Array.map(), we can create a forEach within template literals.
*/
var items = [
{ name: 'Teddy' },
{ name: 'Dolores' },
{ name: 'William' },
{ name: 'Bernard' }
@AleeRojas
AleeRojas / popover-dom-content.html
Created March 16, 2018 12:02 — forked from imliam/popover-dom-content.html
Bootstrap 4 - Load Popover Content From DOM
<div id="unique-id" style="display:none;">
<div class="popover-heading">This is a heading</div>
<div class="popover-body">This is HTML content that will be loaded inside a </div>
</div>
<span tabindex="0" role="button" data-toggle="popover" data-placement="bottom" data-popover-content="#unique-id">
Click me to load a popover
</span>
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@AleeRojas
AleeRojas / leftjoint.php
Last active April 19, 2016 19:39
Left Join Laravel
<?php
$model = $model->leftJoin('history', function ($join) {
$join->on('history.record_id', '=', 'work_order.work_order_id');
$join->where('history.tablename', '=', 'test');
$join->where('history.columnname', '=', 'column');
$join->where(DB::raw('(`history`.`value_from` = 0 or `history`.`value_from` = "")'), '', '');
$join->where('history.value_to', '>', '0');
});
@AleeRojas
AleeRojas / ajax-modal.js
Created February 18, 2016 16:21
Ajax y Modal Semantic-UI
$('body').on('click', '.ajax-modal', function() {
$('.ui.modal')
.modal({
onShow: function(callback) {
callback = $.isFunction(callback) ? callback : function(){};
var $content = $(this).find('.content');
$.get("contentData.php", function(data) {
$content.html(data);
});
}