Skip to content

Instantly share code, notes, and snippets.

View vitaliel's full-sized avatar

Vitalie Lazu vitaliel

  • Moldova, Chisinau
View GitHub Profile
@vitaliel
vitaliel / password-input.component.html
Created January 13, 2023 12:47
Angular password component
<div class="input-group">
<input [type]="fieldTextType ? 'text' : 'password'" class="form-control"
placeholder="Password"
[id]="formControlName"
[formControl]="control" />
<div class="input-group-append">
<span class="input-group-text">
<i
class="fa"
[ngClass]="{
@vitaliel
vitaliel / customer_index.rb
Last active December 18, 2023 20:06
SearchFlip: Opensearch, skip ssl verification
# Skip ssl verification for local opensearch service
class CustomerIndex
include SearchFlip::Index
# Tested on OpenSearch 1.3 and 2.5
def self.connection
ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
http_client = SearchFlip::HTTPClient.new(plugins: [
@vitaliel
vitaliel / AngleCheck.cs
Created October 27, 2021 14:46
POC for replacing inline images with separate http requests
using System;
using System.Linq;
using AngleSharp.Html.Parser;
namespace ParsingCheck
{
public class AngleCheck
{
// POC for replacing inline images with separate http requests
// AngleSharp v0.16.1
-- Show FKeys
SELECT
tc.table_schema,
tc.constraint_name,
tc.table_name,
kcu.column_name,
ccu.table_schema AS foreign_table_schema,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
<%- headers = ['Identifier', 'Service', 'Start time', 'Called Number', 'Duration (seconds)', 'price'] -%>
<%= CSV.generate_line headers -%>
<%- cdrs_collection.find_each do |record| -%>
<%= CSV.generate_line([record.id, record.customer_service.name, record.start, URI.decode(record.called), record.billsec, number_to_currency(record.price)]) -%>
<%- end -%>
# Ported code from https://stackoverflow.com/questions/46888656/how-to-check-password-in-node-js-from-aspnetusers-net-core
# ruby 2.5.1
require "base64"
require "openssl"
# Value from table AspNetUsers, PasswordHash field
h="AQAAAAEAACcQAAAAEFzA9xEehSfcI4qgvuIPlkAXTzLrPuvVtVDW3g4+QHTR4XoIzXUikDJITOi82f4qWQ=="
h_bytes = Base64.decode64(h)
#!/usr/bin/env ocaml
#load "str.cma";;
let concat_file_parts l =
String.concat "." l;;
let change_ext name ext =
let old_parts = String.split_on_char '.' name in
match List.rev old_parts with
@vitaliel
vitaliel / run.rb
Created November 28, 2013 09:42
run rails with thin and tail -f for development.log that outputs rails logs to the console
require 'thread'
log='log/development.log'
system "truncate --size 0 #{log}"
Thread.new do
system('bundle exec thin start')
end
args = %W{tail -f #{log}} + [:err => [:child, :out]]
@vitaliel
vitaliel / check_dj.rb
Created November 8, 2013 14:58
Nagios plugin to monitor delayed job active record queue
#!/usr/bin/env ruby
# encoding: utf-8
#
# Nagios plugin to monitor delayed job active record queue
#
# will use mysql2 gem
# --dsn mysql2://root@localhost/portal_development
#
@vitaliel
vitaliel / clean_linux_pkg.rb
Created November 6, 2013 07:14
Remove old linux packages from ubuntu/debian
keep=%w{3.5.0-41 3.5.0-42}
versions = Dir['/boot/System.map*'].sort.map do |f|
name = File.basename(f)
if name =~ /(\d+\.\d+\.\d+-\d+)/
$1
end
end
pkgs = []