how to create a new user in MySQL
// then:
mysql% GRANT ALL PRIVILEGES ON *.* TO 'jm3_spoon'@'localhost' IDENTIFIED BY 'stirthatshit' WITH GRANT OPTION; mysql% create database jm3_agitator;
11281 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
mysql% GRANT ALL PRIVILEGES ON *.* TO 'jm3_spoon'@'localhost' IDENTIFIED BY 'stirthatshit' WITH GRANT OPTION; mysql% create database jm3_agitator;
declare @name nvarchar(32), @sql nvarchar(1000) -- find constraint name select @name = O.name from sysobjects AS O left join sysobjects AS T on O.parent_obj = T.id where isnull(objectproperty(O.id,'IsMSShipped'),1) = 0 and O.name not like '%dtproper%' and O.name not like 'dt[_]%' and T.name = 'MyTable' and O.name like 'DF__MyTable__MyColu%' -- delete if found if not @name is null begin select @sql = 'ALTER TABLE [MyTable] DROP CONSTRAINT [' + @name + ']' execute sp_executesql @sql end -- do your ALTER TABLE here -- replace the constraint select @sql = 'ALTER TABLE [MyTable] ADD CONSTRAINT [' + @name + '] DEFAULT (0) FOR [MyColumn]' execute sp_executesql @sql
conditions = ['active = ? and type = ?', true, 2] conditions.add_condition ['person_id = ?', 345]
class Array def add_condition(condition, conjunction='and') if condition.is_a? Array if self.empty? (self << condition).flatten! else self[0] += " #{conjunction} " + condition.shift (self << condition).flatten! end elsif condition.is_a? String self[0] += " #{conjunction} " + condition else raise "don't know how to handle this condition type" end self end end
SELECT * FROM texts WHERE content REGEXP '[^a-z]Hello[^a-z]' ;
SELECT * FROM texts WHERE content REGEXP BINARY '[^a-zA-Z]Hello[^a-zA-Z]' ;
SELECT * FROM texts WHERE content REGEXP '[^\w]Hello[^\w]' ;
CREATE VIEW gpsGlb AS SELECT LocID ,6378 * COS(RADIANS(Latitude)) * COS(RADIANS(Longitude)) AS x ,6378 * COS(RADIANS(Latitude)) * SIN(RADIANS(Longitude)) AS y ,6378 * SIN(RADIANS(Latitude)) AS z FROM station;
SELECT LocID ,ROUND((2 * 6378 * ASIN(d / 2 / 6378)) * 0.621371192) AS dist_mi FROM (SELECT SQRT(dx * dx + dy * dy + dz * dz) AS d ,LocID FROM (SELECT p1.x - p2.x AS dx ,p1.y - p2.y AS dy ,p1.z - p2.z AS dz ,p2.LocID FROM gpsGlb p1 JOIN gpsGlb p2 ON (p1.LocID = 405 AND p2.LocID != 405) ) t1 ) t2 ORDER BY dist_mi
SELECT LocID ,(360 + DEGREES(ATAN2(y, x))) % 360 AS initBearing_deg ,ROUND(((360 + DEGREES(ATAN2(y, x))) % 360) / 22.5) * 22.5 AS initBearingBoxed_deg FROM (SELECT SIN(RADIANS(s2.Longitude - s1.Longitude)) * COS(RADIANS(s2.Latitude)) AS y ,COS(RADIANS(s1.Latitude)) * SIN(RADIANS(s2.Latitude)) - SIN(RADIANS(s1.Latitude)) * COS(RADIANS(s2.Latitude)) * COS(RADIANS(s2.Longitude - s1.Longitude)) AS x ,s2.LocID FROM station s1 JOIN station s2 ON (s1.LocID = 405 AND s2.LocID != 405) ) q1
SELECT qq2.LocID ,dist_mi ,CASE initBearingBoxed_deg WHEN 22.5 THEN 'NNE' WHEN 45 THEN 'NE' WHEN 67.5 THEN 'ENE' WHEN 90 THEN 'E' WHEN 112.5 THEN 'ESE' WHEN 135 THEN 'SE' WHEN 157.5 THEN 'SSE' WHEN 180 THEN 'S' WHEN 202.5 THEN 'SSW' WHEN 225 THEN 'SW' WHEN 247.5 THEN 'WSW' WHEN 270 THEN 'W' WHEN 292.5 THEN 'WNW' WHEN 315 THEN 'NW' WHEN 337.5 THEN 'NNW' ELSE 'N' END AS bearing FROM ( SELECT LocID ,ROUND((2 * 6378 * ASIN(d / 2 / 6378)) * 0.621371192) AS dist_mi FROM (SELECT SQRT(dx * dx + dy * dy + dz * dz) AS d ,LocID FROM (SELECT p1.x - p2.x AS dx ,p1.y - p2.y AS dy ,p1.z - p2.z AS dz ,p2.LocID FROM gpsGlb p1 JOIN gpsGlb p2 ON (p1.LocID = 405 AND p2.LocID != 405) ) t1 ) t2 ) qq1 JOIN ( SELECT LocID ,(360 + DEGREES(ATAN2(y, x))) % 360 AS initBearing_deg ,(360 + ROUND((DEGREES(ATAN2(y, x))) / 22.5) * 22.5) % 360 AS initBearingBoxed_deg FROM (SELECT SIN(RADIANS(s2.Longitude - s1.Longitude)) * COS(RADIANS(s2.Latitude)) AS y ,COS(RADIANS(s1.Latitude)) * SIN(RADIANS(s2.Latitude)) - SIN(RADIANS(s1.Latitude)) * COS(RADIANS(s2.Latitude)) * COS(RADIANS(s2.Longitude - s1.Longitude)) AS x ,s2.LocID FROM station s1 JOIN station s2 ON (s1.LocID = 405 AND s2.LocID != 405) ) q1 ) qq2 ON (qq1.LocID = qq2.LocID AND qq1.dist_mi <= 60) ORDER BY dist_mi
create proc usp_srchDir ( @pathName nvarchar(100), @strDirName nvarchar(50), @ExactName nvarchar(20) OUTPUT ) AS BEGIN SET NOCOUNT ON DECLARE @strCMD nvarchar(500) SET @strCMD='dir "'+ @pathName +'" /ad/o | find /I "'+@strDirName+'"' create table tblFindDIR(SearchDIRName nvarchar(200)) insert into tblFindDIR(SearchDIRName) exec master.dbo.xp_cmdshell @strCMD delete from tblFindDIR where isnull(SearchDIRName,'')='' select @ExactName=ltrim(rtrim(right(SearchDIRName,20))) from tblFindDIR where SearchDIRName like '%'+@strDirName+'%' drop table tblFindDIR SET NOCOUNT OFF END GO
... mysql_query( "SET NAMES 'utf8' " ); ...
function f_magic_quotes($text) { if ( !get_magic_quotes_gpc() ) { return addslashes($text); } else { return $text; } }
function f_clean_quotes($text) { if ( !get_magic_quotes_gpc() ) { return $text; } else { return stripslashes($text); } }
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"> <etl> <properties> <!-- Configure table name --> table_name=test </properties> <connection id="in" driver="auto" url="jdbc:oracle:thin:@localhost:1521:ORCL" classpath="ojdbc14.jar" user="scott" password="tiger"/> <connection id="out" driver="csv" url="${table_name}_${etl.date.now('MM_dd_yyyy')}.csv" /> <query connection-id="in"> <!-- Query table rows --> SELECT * FROM ${table_name} <script connection-id="out"> <!-- Export each row into a CSV --> $ID, $Name, $Surname <!-- Use column names from selected table --> </script> </query> </etl>
ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_database.log")