Skip to content

Instantly share code, notes, and snippets.

View nickyrabit's full-sized avatar
🏠

Nicholaus Legnard nickyrabit

🏠
View GitHub Profile
@nickyrabit
nickyrabit / cheatsheet.txt
Last active June 16, 2018 17:26
On Heroku, Flask and PostgreSQL (Simple CheatSheet)
So as im learning Flask and PostgreSQL, and i have been learning to host the Flask app into Heroku and i found some of these tiny tips for you guys to know because it
may be hard for you guys who are beginners like me to maneouver in this envirinment
ENABLE LOGGIN IN HEROKU
heroku logs --tail
TO ALLOCATE YOUR DABATABASE IN HEROKU CLI (COMMAND PROMPT RECEIVING HEROKU COMMANDS)
heroku pg:psql "POSTGREAPP NAME" --app ""database name"
@nickyrabit
nickyrabit / nulljson.java
Last active April 15, 2019 10:59
How to handle null json key when processing JSON Object in Java and Android
//in my example im creating a json object from json array
JSONObject object = jArr.getJSONObject(i);
//getting an JSONArray from JSONObject
JSONArray roleJSONArray = object.getJSONArray("roles");
//This is where i check the null json object if "location" value comes null
//Step 1: check if its null using isNull
if(object.isNull("location")){
//override the key value from location to another value
object.put("location", "N/A");
@nickyrabit
nickyrabit / newfragment.java
Created March 21, 2019 12:50
Open a new Fragment by replacing the current one
//this is the method
//R.id.frame should be R.id.name_of_your_frame_layout
public void goToFragment(Fragment fragment) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
@nickyrabit
nickyrabit / refresh_materialized_views.sql
Last active April 17, 2023 11:01
PostgreSQL Script to Refresh All Materialized Views in your database dynamically
CREATE OR REPLACE FUNCTION refresh_all_materialized_views()
RETURNS VOID AS $$
DECLARE
matview RECORD;
total_views INTEGER;
views_processed INTEGER := 0;
BEGIN
SELECT COUNT(*) INTO total_views FROM pg_matviews;
FOR matview IN (SELECT schemaname, matviewname FROM pg_matviews)
LOOP