Skip to content

Instantly share code, notes, and snippets.

View tonyvince's full-sized avatar
🌊

Tony Vincent tonyvince

🌊
  • Berlin, Germany
  • 09:56 (UTC +01:00)
View GitHub Profile
@aquajach
aquajach / protected_zipped_csv_json.rb
Last active May 25, 2024 10:32
Password protected zip file with csv/json data inside
compressed_filestream = Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new('password')) do |zos|
#First file
zos.put_next_entry "test1.csv"
csv = CSV.generate do |csv|
User.all.each do |user|
csv << [user.id, user.name]
end
csv << values
end
zos.print csv
@amolkhanorkar
amolkhanorkar / PG::Error: ERROR: new encoding (UTF8) is incompatible
Last active August 30, 2024 13:31
Postgres PG::Error: ERROR: new encoding (UTF8) is incompatible
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
@initbrain
initbrain / screenshot.py
Last active June 1, 2023 14:02
Python screenshot tool (fullscreen/area selection)
#!/usr/bin/env python3
# Python screenshot tool (fullscreen/area selection)
# Special thanks to @tomk11, @frakman1, @aspotton and @lucguislain for the improvements
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import QPixmap, QScreen
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSizePolicy
from PyQt5.QtWidgets import QGroupBox, QSpinBox, QCheckBox, QGridLayout
from PyQt5.QtWidgets import QPushButton, QHBoxLayout, QVBoxLayout
# config/initializers/omnicontacts.rb
Rails.application.middleware.use OmniContacts::Builder do
importer :live, 'client_id', 'client_secret', {redirect_path: "/invitations/live/contact_callback"}
end
class OmniContacts::Importer::Live < OmniContacts::Importer::Hotmail
def initialize *args
super *args
#!/usr/bin/env ruby
require 'csv'
require 'json'
if ARGV.size != 2
puts 'Usage: csv_to_json input_file.csv output_file.json'
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects'
exit(1)
end