Skip to content

Instantly share code, notes, and snippets.

View dereknguyen269's full-sized avatar
👋
I may be slow to respond.

dereknguyen269

👋
I may be slow to respond.
View GitHub Profile
0x636c48edbedd078cd9e196dc6c2154c7f82e73b0
@dereknguyen269
dereknguyen269 / main.go
Created October 27, 2023 07:02
Go Code Demo
package main
import "fmt"
func main() {
// Declare a variable of type int
var age int
// Get the user's age
fmt.Println("Enter your age:")
@dereknguyen269
dereknguyen269 / metaprogramming.md
Created December 5, 2022 03:19 — forked from BrianSigafoos/metaprogramming.md
Metaprogramming in Ruby

Dynamic Method

# Decide how to define a method at runtime
class C
end

C.class_eval do
  define_method :my_method do
    'a dynamic method'
 end
@dereknguyen269
dereknguyen269 / curl.md
Created October 14, 2022 09:12 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dereknguyen269
dereknguyen269 / setup_railson_mac_m1.md
Last active May 25, 2023 14:31
Setup project rails 4.2.x and ruby 2.5.x on Mac M1

I've some problem when setup project with:

  • Rails 4.2.10
  • Ruby 2.5.3
  • Postgresql 13

My steps:

Install Homebrew

@dereknguyen269
dereknguyen269 / calculate.rb
Created September 30, 2020 08:13
Distance between two points on earth with Ruby
# https://www.geeksforgeeks.org/program-distance-two-points-earth/
earthRadius = 6371 # km
d_lat = (origin[:lat] - destination[:lat]) / 180.0 * Math::PI
d_lng = (origin[:lng] - destination[:lng]) / 180.0 * Math::PI
sin_lat = Math.sin(d_lat / 2)
sin_lng = Math.sin(d_lng / 2)
rad_lat1 = origin[:lat] / 180.0 * Math::PI
rad_lat2 = destination[:lat] / 180.0 * Math::PI
a = (sin_lat * sin_lat) + (sin_lng * sin_lng) * Math.cos(rad_lat1) * Math.cos(rad_lat2)
@dereknguyen269
dereknguyen269 / curl
Created June 24, 2020 13:17
How To Check URL Is Working Or Not In Programing Languages?
$url = "http://www.domain.com/demo.jpg";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
$result = curl_exec($curl);
if ($result !== false)
{
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 404)
{
echo "URL Not Exists"
@dereknguyen269
dereknguyen269 / queries_and_update_property_in_json_column_with_rails.rb
Last active March 13, 2020 03:08
Queries And Update Property In JSON Column With Rails
# Table Driver
# Id : Integer
# Name : String
# Vehicle Attributes : JSON
# Example:
# {
# id: 1,
# name: 'Driver Name',
# vehicle_attributes: {
$('.container-fluid').find('form.mobile-price-area').parent().removeClass('col-lg-5').addClass('col-lg-12')
var __extends = (this && this.__extends) || (function() {
var a = Object.setPrototypeOf || ({
__proto__: []
}instanceof Array && function(e, c) {
e.__proto__ = c
}
) || function(f, c) {
for (var e in c) {
if (c.hasOwnProperty(e)) {
RIFF6MTDFmtdp0100pginÄC†2Z,r.•@LIST˚INFOIppn
MN0195075Icpd2010ICOPû© 2010 Dalmatian Music and Universal Music Publishing MGB Limited
This arrangement © 2019
All Rights Reserved.
[Based on "Canon in D" by Johann Pachelbel]IcarAIpmg Nauman, TomISFT MusE 434.0ITCHLucas KoehlerItonC MajorIfsb270INAMBeautiful in WhiteIpag6Idif7ICRD2010Imet4:4Imtnq = 80Isnm(based on Pachelbel's Canon)Itia Canon in DItooC MajorIcexFor sale worldwideIbpkUNIsan92540Ilcm2ISRC!Universal Music Publishing GroupIpptmnIpri31ImgpKusuma, RiyandiImgnKusuma, RiyandiImgn
Filan, ShaneIART
Filan, ShaneIARTPachelbel, JohannIlyr
Filan, ShaneIarrKusuma, RiyandiIpalPachelbel, JohannesIKEY westlifeIGNRSoloIinsPianoIforInstrumental SoloIstyWeddingIstySolo InstrumentalIstyPopIstyAdult ContemporaryIpdd2019-04-08T20:23:45ZIpopwww.musicnotes.comIdlr Musicnotesmfntj
#! #1 #C#S#CDoremiTimes-BoldTimes-ItalicHelveticaHelvetica-ObliqueHelvetica-BoldLISTÑmtdPmtdcwe<!≈†ÖôLÒd>NZ˜/Fµ≥<ÒÀ+¥N≈”ï˛mÖê^T,X:ƒ‰ f™ZlT