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 March 20, 2025 12:19
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");
}
}
@JamieMason
JamieMason / unfollow.js.md
Last active February 24, 2026 08:19
Unfollow everyone on twitter.com

Unfollow everyone on twitter.com

By @foldleft.bsky.social, see also Unfollow everyone on bsky.app.

  1. Go to https://twitter.com/YOUR_USER_NAME/following
  2. Open the Developer Console. (COMMAND+ALT+I on Mac)
  3. Paste this into the Developer Console and run it
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)