Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import { select, geoMercator, geoPath, zoom, json } from 'd3';
class WorldMap extends Component {
componentDidMount() {
this.drawMap();
window.addEventListener('resize', this.handleResize);
}
componentWillUnmount() {
@jquery404
jquery404 / PC Central.vba
Created December 20, 2018 03:23
Console - Combine - Save - Clear
Sub Console()
Dim FolderPath As String
Dim Filename As String
Dim sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = GetFolder & "\"
@jquery404
jquery404 / Async HTTP call AngularJS.html
Last active November 8, 2018 07:35
Async HTTP call AngularJS
<div class="col-md-6 col-sm-6 col-xs-12">
<select
ng-change="changeCluster(1)"
ng-options="s.cluster_id as s.cluster_title for s in parentLevel"
ng-model="currentCluster.co_sub_cluster">
</select>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="clearfix">
@jquery404
jquery404 / .htaccess
Created November 1, 2018 10:26
Remove .php from .htaccess
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this:
var goal = 25;
var numbers = [21, 34, 12, 52, 43];
var closest = numbers.reduce(function(prev, cur){
return (Math.abs(cur-goal) < Math.abs(prev-goal)) ? cur : prev;
});
console.log(closest); // output: 21
@jquery404
jquery404 / Circular Image.html
Created October 18, 2018 04:44
get circular image for any size of picture
<style>
.circular {
width: 150px;
height: 150px;
border-radius: 50%;
position: relative;
overflow: hidden;
margin: 0 auto;
}
.circular img {
@jquery404
jquery404 / jqueryAngularDirective.html
Last active October 10, 2018 07:40
jQuery Plugin to Angular Directive
<input jqdaterangepicker type="text" class="form-control" ng-model="daterange" ng-change="onDateRangeChange()" />
<input
jqdatepicker
type="text"
name="dueStartDate"
datetime="dd-MM-yyyy"
data-date-format="dd-mm-yyyy"
class="form-control"
placeholder="Due Date (From)"
ng-model="selectedEdit.field" />
@jquery404
jquery404 / File Upload.html
Created September 14, 2018 04:06
File upload service for angularjs
<html>
<form ng-submit="SubmitAssignment()" enctype="multipart/form-data">
<div class="form-group">
<label class="control-label">Upload File</label>
<input type="file" file-model="myFile" />
</div>
<button class="btn btn-info" type="submit">Submit</button>
</form>
@jquery404
jquery404 / Pagination.html
Last active September 12, 2018 08:22
Angular and Bootstrap UI pagination
<div class="info">
Showing {{entryLimit*(currentPage-1)+1}} to {{entryLimit*(currentPage-1)+entryLimit}} of {{totalItems}} entries
</div>
<div ng-repeat="data in filtered = (activity) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
<td>{{entryLimit *(currentPage-1)+$index+1}}</td>
</div>
<div
pagination
@jquery404
jquery404 / Distance.sql
Created July 6, 2018 06:26
Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and l…
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) )
* cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin(radians(lat)) ) ) AS distance
FROM markers
HAVING distance < 25
ORDER BY distance
LIMIT 0 , 20;