Skip to content

Instantly share code, notes, and snippets.

@jaimeguaman
jaimeguaman / gist:eba17813b218696993e7f7d543b9c20d
Created July 16, 2020 23:35 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@jaimeguaman
jaimeguaman / pmt.js
Created September 15, 2019 14:43 — forked from maarten00/pmt.js
Excel PMT in PHP and JavaScript
/**
* Copy of Excel's PMT function.
* Credit: http://stackoverflow.com/questions/2094967/excel-pmt-function-in-js
*
* @param rate_per_period The interest rate for the loan.
* @param number_of_payments The total number of payments for the loan in months.
* @param present_value The present value, or the total amount that a series of future payments is worth now;
* Also known as the principal.
* @param future_value The future value, or a cash balance you want to attain after the last payment is made.
* If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0.
/***************************************
Responsive Helper
Usage:
.my-box {
padding: 10px;
@include for-size(tv) {
padding: 80px;
}
@include for-size(desktop-up) {
@jaimeguaman
jaimeguaman / keybase.md
Last active August 29, 2015 14:04
keybase.md

Keybase proof

I hereby claim:

  • I am jaimeguaman on github.
  • I am jaime (https://keybase.io/jaime) on keybase.
  • I have a public key whose fingerprint is 04E2 4F5D 38EE 5EFE A964 0958 0A55 EBBD F48A 7D84

To claim this, I am signing this object:

@jaimeguaman
jaimeguaman / dabblet.css
Created March 18, 2014 03:38
Facebook Loader Fake UI
/**
* Facebook Loader Fake UI
*/
@-webkit-keyframes loaderFx{
0%{
background-position:-460px 0
}
100%{
background-position:460px 0
}
@jaimeguaman
jaimeguaman / dabblet.css
Created September 16, 2013 18:21
CSS Gradient Yin Yang.
/* CSS Gradient Yin Yang. */
html{
background: radial-gradient(circle at 50% 33.3%, black 3%, white 2%, white 17.8%, transparent 0) no-repeat, radial-gradient(circle at 50% 66.8%, white 3%, black 2%, black 17.8%, transparent 0) no-repeat, radial-gradient(circle at 50% 50%, transparent 40%, black 41%, white 25%)no-repeat, -webkit-linear-gradient(left, white 50%, black 50%) no-repeat;
background-size:800px 600px;
}
@jaimeguaman
jaimeguaman / dabblet.css
Created September 16, 2013 02:32
CSS Gradient Yin Yang. NO More before & after PLS
/* CSS Gradient Yin Yang. NO More before & after PLS */
.shinshan{
width:40%;
height:500px;
margin:0 auto;
border-radius:50%;
overflow:hidden;
border:2px solid black;
/* chrome (webkit, blink), firefox, opera and safary (I guess). IE, you just fuck off */
background:
@jaimeguaman
jaimeguaman / urlsearch
Created August 9, 2013 19:01
get url action and url parameters javascript
function getURLAction(action){
var posibleAction=window.location.hash.replace(/^#\/?/, "");
posibleAction=posibleAction.substring(0,posibleAction.indexOf('?'));
return posibleAction==action ? true : false
}
function getURLParameter(name,inHashSearch){
var searchScope=inHashSearch ? window.location.hash : location.search;
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(searchScope)||[,""])[1].replace(/\+/g, '%20'))||null;
}
@jaimeguaman
jaimeguaman / regex_telefonos_fijos_chile
Last active September 25, 2020 01:29
regex telefonos fijo chile
/^((\+?56\s)?(0?2|0?3[2-5]|0?4[1-5]|0?5[123578]|0?6[13457]|0?7[1235])?(\s2\d{6}|\s\d{6}))$/
'+56 2 2xxxxxx',
'+56 51 2xxxxxx',
'+56 51 xxxxxx',
'56 75 xxxxxx',
'56 051 xxxxxx',
'56 051 2xxxxxx',
'+56 051 2xxxxxx'
@jaimeguaman
jaimeguaman / regex_celulares_chile
Last active March 23, 2024 01:30
regex validacion celulares chile
/^(\+?56)?(\s?)(0?9)(\s?)[98765432]\d{7}$/