Skip to content

Instantly share code, notes, and snippets.

View wallacemaxters's full-sized avatar

Wallace Maxters wallacemaxters

View GitHub Profile
@huzemin
huzemin / laravel-encrypt.js
Created December 3, 2019 06:47
laravel Encrypt convert to CryptoJS in Javascript
import CryptoJS from "crypto-js";
const LaravelEncrypt = function (key) {
this.key = key;
}
LaravelEncrypt.prototype.decrypt = function (encryptStr) {
encryptStr = CryptoJS.enc.Base64.parse(encryptStr);
let encryptData = encryptStr.toString(CryptoJS.enc.Utf8);
encryptData = JSON.parse(encryptData);
@abiusx
abiusx / array_key_map.php
Last active June 25, 2024 12:38
PHP's array_map, but instead of mapping values, maps keys.
<?php
/**
* Array map, but maps values to new keys instead of new values
* @return array same arrays with keys mapped
*/
function array_map_key($callback,$array)
{
$out=array_reduce($array, function ($carry,$val) use ($array,$callback){
$key=call_user_func($callback,$val);
$carry[$key]=$val;
@jfbueno
jfbueno / Program.cs
Last active February 7, 2018 11:07
SimpleDateTimeApi
using System;
using System.Globalization;
namespace JefersonBueno
{
public class Program
{
public static string ChangeDate(string date, char op, long value)
{
var toAdd = Math.Abs(value);
@wemersonjanuario
wemersonjanuario / saveas.js
Created December 23, 2017 03:18 — forked from rreimi/saveas.js
Ajax blob save as.. file download
var url = 'http://www.pdf995.com/samples/pdf.pdf';
var fileName = 'pdf.pdf';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onprogress = function(pe) {
console.log('progress');
if (pe.lengthComputable) {
console.log((pe.loaded / pe.total) * 100);
@wallacemaxters
wallacemaxters / Routing.py
Created November 4, 2016 17:43
provides a classes for easy routing with python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
class NotMatchingException(Exception):
pass
"""
This class represente a route
"""
@statickidz
statickidz / nearby-coordinates.sql
Last active September 27, 2024 15:59
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
<?php
function async_request($method, $url, $params, array $headers = [])
{
$method = strtoupper($method);
$data = http_build_query($params);
$parts = parse_url($url) + [
@socieboy
socieboy / gulpfile.js
Created December 2, 2015 04:48
Gulpfile for AdminLTE and Laravel Elixier
var elixir = require('laravel-elixir');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
(function ($) {
var defaults = {
cache: false,
contentType: false,
processData: false,
type: 'POST',
onProgress: new Function,
xhr: function (xhr) {
@jkeck
jkeck / svg-pie-chart.css
Created November 14, 2015 06:22
Simple SVG Pie Chart
svg {
width: 100px;
border-radius: 50%;
background:yellowgreen;
transform: rotate(-90deg);
}
circle {
fill: none;
stroke-width: 32;