- images:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connection, transaction | |
cursor = connection.cursor() | |
cursor.execute("UPDATE yourtablename SET field1=value1, .. WHERE .. ") | |
transaction.set_dirty() | |
transaction.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file libs/dbutil.py | |
from itertools import * | |
from django.db import connection | |
def query_to_dicts(query_string, *query_args): | |
cursor = connection.cursor() | |
cursor.execute(query_string, query_args) | |
col_names = [desc[0] for desc in cursor.description] | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql2' | |
db = Mysql2::Client.new(:host => 'localhost', :username => 'root', :password=> 'password', :database => 'db_name' ) | |
res = db.query("select * from users") | |
res.each do |row| | |
col1 = row['id'] | |
col2 = row['email'] | |
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.maxivak.utils; | |
import java.io.*; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.net.Uri; | |
import android.util.Log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. connection.select_values or connection.select_all | |
ids = ActiveRecord::Base.connection.select_values("select id from users WHERE ...") | |
# array of integers | |
# ["1", "2", "5", "6", "7", "8", "3", "10", "11", "9"] | |
# return hashes without model | |
sql = "sql query" | |
rows = User.connection.select_all(sql.squish!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. connection.select_values or connection.select_all | |
ids = ActiveRecord::Base.connection.select_values("select id from users WHERE ...") | |
# array of integers | |
# ["1", "2", "5", "6", "7", "8", "3", "10", "11", "9"] | |
# return hashes without model | |
sql = "sql query" | |
rows = User.connection.select_all(sql.squish!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# put in /etc/munin/plugins and restart munin-node | |
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin | |
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title Passenger memory stats | |
graph_vlabel count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
around_filter :gc_disable | |
private | |
def gc_disable | |
GC.disable | |
begin | |
yield | |
ensure |