Skip to content

Instantly share code, notes, and snippets.

View maprangsoft's full-sized avatar
💭
i love programming

Maprangsoft maprangsoft

💭
i love programming
View GitHub Profile
@mennwebs
mennwebs / th-address.json
Created November 20, 2023 02:16
Thai Address from Postal Code - JSON
This file has been truncated, but you can view the full file.
[
{
"zipCode": "10100",
"subDistrictList": [
{
"subDistrictId": "100801",
"districtId": "1008",
"provinceId": "10",
"subDistrictName": "ป้อมปราบ"
@tomholford
tomholford / install_pg_gem.md
Last active May 18, 2024 07:30
Install postgresql gem `pg` on macOS

Installing pg gem on macOS

If you're trying to install the postgresql gem pg and it is failing with the following error message:

Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pg-1.2.3/ext
~/.rbenv/versions/3.0.0/bin/ruby -I ~/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20210125-97201-pycpo.rb extconf.rb
@casperwilkes
casperwilkes / SoftDeletesTrait.php
Created March 2, 2020 16:06
Laravel override trait for soft deletes that recognizes the observer
<?php
/**
* Overrides original SoftDeletes::runSoftDelete method to include observer changes in `deleting` event.
* @see SoftDeletes
* @uses SoftDeletes::runSoftDelete()
*/
namespace App\Traits;
@thangman22
thangman22 / pwa-prompt.js
Last active January 30, 2024 05:24
PWA Prompt
var deferredPrompt
// Event นี้จะเกิดขึ้นตอนที่ Banner จะโผล่ขึ้นมา
window.addEventListener('beforeinstallprompt', e => {
// บังคับไม่ให้ Banner ของ Browser ทำงาน
e.preventDefault();
// เก็บตัวแรก event ไว้ใช้ต่อ
deferredPrompt = e;
@nhatnx
nhatnx / is_equal_objects.js
Last active March 12, 2023 02:02
Compare 2 objects recursively (if don't want to use lowdash _isEqual)
// https://gomakethings.com/check-if-two-arrays-or-objects-are-equal-with-javascript/
var isEqual = function (value, other) {
// Get the value type
var type = Object.prototype.toString.call(value);
// If the two objects are not the same type, return false
if (type !== Object.prototype.toString.call(other)) return false;
// If items are not an object or array, return false

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@ye-fight
ye-fight / replace-zero-width-space.php
Created February 27, 2018 01:05 — forked from ahmadazimi/replace-zero-width-space.php
PHP replace Zero Width Space using preg_replace
<?php
/**
* http://stackoverflow.com/questions/11305797/remove-zero-width-space-characters-from-a-javascript-string
* U+200B zero width space
* U+200C zero width non-joiner Unicode code point
* U+200D zero width joiner Unicode code point
* U+FEFF zero width no-break space Unicode code point
*/
@brunogaspar
brunogaspar / macro.md
Last active May 1, 2024 07:24
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@arahmanali
arahmanali / mongoose-sum-fields.js
Last active June 19, 2022 10:08
Mongoose sum and group model's field.
/* fetch all users user_totaldocs and user_totalthings values and want to sum those variables.*/
var userSchema = mongoose.Schema({
local : {
...
...
user_id : String,
user_totaldocs : Number,
user_totalthings : Number
....
@yckart
yckart / jquery.addrule.js
Last active December 29, 2022 12:16
Add css-rules to an existing stylesheet - http://stackoverflow.com/a/16507264/1250044
/*!
* jquery.addrule.js 0.0.2 - https://gist.github.com/yckart/5563717/
* Add css-rules to an existing stylesheet.
*
* @see http://stackoverflow.com/a/16507264/1250044
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/11/23
**/