Skip to content

Instantly share code, notes, and snippets.

View jackyvo's full-sized avatar

Jacky Vo jackyvo

View GitHub Profile
@jackyvo
jackyvo / clean_users.sql
Last active April 12, 2022 17:08
clean_users.sql
ALTER TABLE users ADD COLUMN need_deleted BOOLEAN DEFAULT true;
UPDATE users SET need_deleted=false where id IN (select DISTINCT(user_id) from enrollments);
DELETE FROM eportfolio_entries WHERE eportfolio_id in (select id FROM eportfolios where user_id IN (SELECT id FROM users where need_deleted=true));
DELETE FROM eportfolio_categories WHERE eportfolio_id in (select id FROM eportfolios where user_id IN (SELECT id FROM users where need_deleted=true));
DELETE FROM eportfolios where user_id IN (SELECT id FROM users where need_deleted=true);
DELETE FROM account_users where user_id IN (SELECT id FROM users where need_deleted=true);
DELETE FROM user_profiles where user_id IN (SELECT id FROM users where need_deleted=true);
@jackyvo
jackyvo / users.rake
Last active April 5, 2022 05:01
Users destroy
# lib/tasks/users.rake
namespace :users do
task spam_clean: :environment do
failed_list = []
no_users_without_enrollments = 0
number_of_thread = (ENV['THREADS'] || 10).to_i
total_users = User.count.to_f
offset = (total_users / number_of_thread).ceil
@jackyvo
jackyvo / users.rb
Created April 3, 2022 14:52
User destroy
#######################################################################
failed_list = []
user_ids_with_enrollment = Enrollment.pluck(:user_id)
users_without_enrollment = User.where.not(id: user_ids_with_enrollment)
users_without_enrollment.find_each do |user|
failed_list << user.id unless user.destroy
end
p "Total users to delete: #{user_without_enrollment.length}"
- (void) findANPRInfo:(FindAnprInfoModel *) anpr andDelegate:(id<FindAnprInfoModelDelegate>) delegate {
if (![anpr.plate isEqualToString:@""] && ![anpr.region isEqualToString:@""] && delegate) {
_delegate = delegate;
}
NSMutableDictionary* parameters = [NSMutableDictionary new];
parameters[@"registration_no"] = anpr.plate;
if ([BPConfiguration loadLoggedStation].identifier > 0) {
parameters[@"device_id"] = [NSString stringWithFormat:@"%@",[BPConfiguration loadLoggedStation].identifier];
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
class MealPreparationTimeEstimateService
def initialize(meal=nil, provider=nil)
@meal = meal
@provider = provider || meal.try(:provider)
end
# Prepare Time: Returns: Time (minutes)
def preparation_time(cache=true)
if cache
time_from_cache || time_for_meal
{
"epoch_start":1525309669055,
"image_car":"http://rohit-ThinkCentre-M72e:32775/img/VK3PS0WWYEDC5KR6FIPIURGXRP82YVV9WZYOFBKD-967255645-
1525309670374.jpg",
"camera_id":967255645,
"frame_start":569031,
"agent_uid":"VK3PS0WWYEDC5KR6FIPIURGXRP82YVV9WZYOFBKD",
"best_confidence":94.99887084960938,
"company_id":"06e41eca-ef94-41f1-8b4b-f6d7008196cb",
@jackyvo
jackyvo / dnsmasq_setup_osx.md
Created May 4, 2018 04:35 — forked from eloypnd/dnsmasq_setup_osx.md
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@jackyvo
jackyvo / Setup_action_cable
Created May 29, 2017 17:20
Carey Deployment
Config Action Cable
1. Edit: /etc/nginx/site-enabled/app.careymedical.com
server {
listen 8888;
server_name app.careymedical.com;
ssl on;
ssl_certificate /etc/ssl/careymedical-chained.crt;
ssl_certificate_key /etc/ssl/careymedical.key;
@jackyvo
jackyvo / sample_search
Last active March 29, 2016 11:47
Sample_Travel_Search_Algorithm