Skip to content

Instantly share code, notes, and snippets.

View WangNingning1994's full-sized avatar
😁
Chill

Wang Ningning WangNingning1994

😁
Chill
View GitHub Profile
@seyuf
seyuf / polygon-center-calculator.js
Last active January 9, 2024 03:04
Calculate GeoJson polygon center in javascript
function area(poly){
var s = 0.0;
var ring = poly.coordinates[0];
for(i= 0; i < (ring.length-1); i++){
s += (ring[i][0] * ring[i+1][1] - ring[i+1][0] * ring[i][1]);
}
return 0.5 *s;
}
@aquilesb
aquilesb / vue.config.js
Created July 10, 2019 02:39
How to add pdf loader to vue-cli's project
module.exports = {
chainWebpack: config => {
config.module.rule('pdf')
.test(/\.(pdf)(\?.*)?$/)
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/pdf/[name].[hash:8].[ext]'
})
@waako
waako / themename.theme.php
Last active June 17, 2019 12:54
Drupal 8: Get Block's parent Node title and full URL
<?php
use Drupal\Core\Url;
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function themename_preprocess_block(&$variables) {
// Get Title of Block's parent Node.
$request = \Drupal::request();
/**
* Custom Style by ninghao.net, based on seti ui & seti syntax theme.
*/
.tab-bar .tab.active:before {
border-bottom: solid 1px #0f4e72;
}
.tab-bar .tab.active {
border-bottom: solid 1px #0f4e72;
}
@getify
getify / gist:11336871
Last active June 14, 2022 05:45
JS scope/hoisting quiz
// Without cheating by running the code,
// what do these 3 result in?
function foo(a) {
a();
function a() {
console.log("yay");
}
}