Skip to content

Instantly share code, notes, and snippets.

View skozz's full-sized avatar
🏠
Working from home

Angel skozz

🏠
Working from home
View GitHub Profile
@skozz
skozz / devise_authentication_api.rb
Last active July 21, 2022 21:34 — forked from marcomd/gist:3129118
Authenticate your API with Devise gem, token by header. Ruby on Rails 4. Read the comments.
#Session controller provides a token
#/controllers/api/sessions_controller.rb
class Api::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create]
before_filter :ensure_params_exist, :except => [:destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:user_login][:email])
return invalid_login_attempt unless resource

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
import csv
import os
import types
from flask import Flask, jsonify, make_response, request, url_for, send_file
from app import celery, firebase, firestore_db
from app.post_tasks import *
from app.master_admin_tasks import check_group_outdated_accounts_token
from firebase_admin import db as firebase_db, firestore
from . import post
from ..models import *
@skozz
skozz / sketch-never-ending.md
Created February 22, 2019 11:21 — forked from Bhavdip/sketch-never-ending.md
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@skozz
skozz / README-Template.md
Created December 13, 2018 08:46 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@skozz
skozz / activerecord_scope_conditions.rb
Created June 28, 2018 12:15 — forked from nathanl/activerecord_scope_conditions.rb
Using joins and conditions in ActiveRecord scopes. (This was hard for me to find documentation on.)
class Person < ActiveRecord::Base
# This manual SQL query...
scope :allowed_to_eat_cheese, joins(
<<-SQL
INNER JOIN cities ON people.city_id = cities.id
INNER JOIN states ON cities.state_id = states.id
SQL
).where('states.allows_cheese_consumption' = 'Yeppers')
"""
Code that goes along with the Airflow tutorial located at:
https://github.com/airbnb/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.generic_transfer import GenericTransfer
from airflow.contrib.hooks import FTPHook
from airflow.hooks.mysql_hook import MySqlHook
@skozz
skozz / check-uri.rb
Created September 26, 2017 09:25 — forked from murdoch/check-uri.rb
Check if uri exists
## just some ways to check if a url exists
# method 1 - from Simone Carletti
require "net/http"
url = URI.parse("http://www.google.com/")
req = Net::HTTP.new(url.host, url.port)
res = req.request_head(url.path)
# method 2 - from some kid on the internet
require 'open-uri'
@skozz
skozz / 1. ELK.install
Created February 3, 2017 09:42 — forked from PavloBezpalov/1. ELK.install
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
INSTALL JAVA
$ sudo apt-get update && sudo apt-get install default-jre
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch
$ sudo update-rc.d elasticsearch defaults 95 10
$ sudo service elasticsearch restart
$ sudo service elasticsearch status
@skozz
skozz / heroku_rails_phantomjs.md
Created August 4, 2016 14:19 — forked from edelpero/heroku_rails_phantomjs.md
Heroku, Ruby on Rails and PhantomJS

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.