Skip to content

Instantly share code, notes, and snippets.

View neutrino's full-sized avatar

ranendra adhikari neutrino

View GitHub Profile
@neutrino
neutrino / cognito-test.py
Created November 1, 2022 09:19 — forked from bgdnlp/cognito-test.py
Sign up and log in to Cognito, check tokens, then call an API. Details: https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
#!/usr/bin/env python3
# Demonstrates the use of Python to work with Cognito.
# Create a new a user, log in, check tokens and call an API.
# The purpose was to learn about Cognito. Security has been
# circumvented in the interest of keeping it simple.
# Notably, the authentication procedure uses the most insecure
# method. This code is not intended for use in production.
#
# https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
@neutrino
neutrino / global-gitignore.md
Created October 28, 2022 15:28 — forked from subfuzion/global-gitignore.md
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file:

  • Create a file called .gitignore in your home directory and add any filepath patterns you want to ignore.
  • Tell git where your global gitignore file is.

Note: The specific name and path you choose aren't important as long as you configure git to find it, as shown below. You could substitute .config/git/ignore for .gitignore in your home directory, if you prefer.

@neutrino
neutrino / nearby-coordinates.sql
Created March 23, 2021 14:50 — forked from statickidz/nearby-coordinates.sql
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@neutrino
neutrino / proxy.rb
Created March 4, 2021 05:50 — forked from tomlea/proxy.rb
Rack Middleware to proxy requests to a remote server. This is usefull for proxying AJAX request to remote services.
require "net/http"
require "enumerator"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
@neutrino
neutrino / stimulus.md
Created November 4, 2020 22:04 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@neutrino
neutrino / pr.md
Created February 8, 2020 05:14 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@neutrino
neutrino / digitalocean.md
Created June 15, 2018 01:40 — forked from JamesDullaghan/digitalocean.md
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@neutrino
neutrino / readme.md
Created June 5, 2018 23:31 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@neutrino
neutrino / database_cleaner.rb
Created December 15, 2015 09:26 — forked from nowlinuxing/database_rewinder.rb
Database cleaner with sharding using ar-octopus
# spec/support/database_cleaner.rb
require 'database_cleaner'
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
actions:
removeSelectedContents: ->
selectedItems = @get('selectedContent') // array of selected items
unless Ember.isEmpty(selectedItems)
userConfirm = confirm('Do you want to delete this items?')
if userConfirm
selectedItems.forEach (item) ->
item.destroyRecord()