working on it ...

Filters

Explore Public Snippets

Sort by

Found 9,813 snippets matching: select

    public by pan  312664  0  7  4

    CSS Regex Selector Extension For jQuery

    Using this extension enables regular expresions css selectors in jQuery
    /**
     * CSS Regex Selector Extension For jQuery
     * 
     */
    jQuery.expr[':'].regex = function(elem, index, match) {
       var matchParams = match[3].split(','),
           validLabels = /^(data|css):/,
           attr = {
               method: matchParams[0].match(validLabels) ?
                   matchParams[0].split(':')[0] : 'attr',
               property: matchParams.shift().replace(validLabels,'')
           },
           regexFlags = 'ig',
           regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
       return regex.test(jQuery(elem)[attr.method](attr.property));
    }

    public by JKCPR  257441  1  6  1

    font: CSS SHORTHAND

    Useful CSS shorthand notation of font: attribute of universal selector of all element(s) descended from the element.
    /* CSS SHORTHAND font: */
    
    body *{
          font: normal 1em/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
        }
    
    /* Equivalent Example
    
    body *{
          font-weight: normal;
          font-size: 1em;
          line-height: 1.5;
          font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        }
          
      */

    public by cghersi  179395  5  7  0

    Apache Cayenne: how to select with Joins

    This is how to create simple queries that use JOIN among several tables. Such tables must be modelled as related in Cayenne modeler. In the example, we have 4 classes in JOIN chain. We want to retrieve all the objects of the 4th class that match the join with the object of the first class with the given id.
    ObjectContext context = getMyContext();
    int id = ...; //the pk of the FirstClass table
    FirstClass n = Cayenne.objectForPK(context, FirstClass.class, id);
    Expression qualifier = ExpressionFactory.matchExp(FourthClass.THIRD_CLASS_PROPERTY + "." + 
    					ThirdClass.SECOND_CLASS_PROPERTY + "." + SecondClass.FIRST_CLASS_PROPERTY, n);
    SelectQuery select = new SelectQuery(FourthClass.class, qualifier);
    List<FourthClass> result = context.performQuery(select);

    public by Fresh-Dev  161690  1  3  0

    Custom Text Selection

    Custom Text Selection: customTextSelection.css
    ::selection { background: #e2eae2; }
    ::-moz-selection { background: #e2eae2; }
    ::-webkit-selection { background: #e2eae2; }
    
    

    public by qxshower  121846  1  5  0

    SelectCodeItem

    Attempts to select the text of the specified code item.
    using EnvDTE;
    using SteveCadwallader.CodeMaid.Model.CodeItems;
    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    
    /// <summary>
    /// Attempts to select the text of the specified code item.
    /// </summary>
    /// <param name="document">The document.</param>
    /// <param name="codeItem">The code item.</param>
    internal static void SelectCodeItem(Document document, BaseCodeItem codeItem)
    {
        var textDocument = document.GetTextDocument();
        if (textDocument == null) return;
    
        try
        {
            codeItem.RefreshCachedPositionAndName();
            textDocument.Selection.MoveToPoint(codeItem.StartPoint, false);
            textDocument.Selection.MoveToPoint(codeItem.EndPoint, true);
    
            textDocument.Selection.SwapAnchor();
        }
        catch (Exception)
        {
            // Select operation may fail if element is no longer available.
        }
        finally
        {
            // Always set focus within the code editor window.
            document.Activate();
        }
    }            

    public by cghersi  8939  31  7  0

    MySQL SELECT statement from blob to string

    SELECT statement to translate a blob field into a readable string
    CREATE TABLE tbl (myBlob longblob);
    
    INSERT INTO tbl VALUES (0x1234);
    
    SELECT 	HEX(myBlob) AS PrintableBlob
    FROM	tbl;

    public by cghersi  6810  14  7  0

    MySQL SELECT Statement From time in milliseconds to date

    The clause in SELECT statement to be used to convert a dateetime stores as milliseconds from Epoch into a Date field
    CREATE TABLE tbl (myTime bigint(20));
    
    INSERT INTO tbl VALUES (1343400240000);
    
    SELECT 	FROM_UNIXTIME(myTime /1000) AS MyDate
    FROM	tbl;

    public by cghersi  3287  1  8  1

    LINQ: How to retrieve an IEnumerable collection with simple query

    This is a simple query in Linq to retrieve the list of Users that have some specified condition (in this case Active == true). Please note the == operator in the where clause (and in general all C# operators apply). Linq is excellent in writing fast and effective in-memory query on lists, dictionaries, etc.
    ICollection<User> users = new List<User>();
    users.Add(new User("Tom"));
    users.Add(new User("Mark"));
    
    IEnumerable<User> result = (
    	from user in users 
    	where user.Active == true 
    	select user); 

    public by cghersi  3111  1  6  1

    How to create a RecordSet in VBA to execute a SELECT query

    This simple method creates and returns a Recordset containing the results of the given SQL query. Note: the caller is in charge to close the recordset and release the resources once done with DB data.
    Public Function ExecQuery(ByVal sql As String) As ADODB.Recordset
    On Error GoTo ErrorCmd
    
      Dim conn As ADODB.Connection
    
      'Init db objects
      'Connection is the current DB one
      If exception_flag Then On Error Resume Next
      Set conn = CurrentProject.Connection
      Set ExecQuery = New ADODB.Recordset
    
      'Exec the query
      Set ExecQuery = CurrentProject.Connection.Execute(sql)
    
    Exit_go: Exit Function
    ErrorCmd: Set ExecQuery = Nothing
    End Function

    public by cghersi  2394  0  7  0

    Apache Cayenne: How to select only PKs

    This is how to perform a query that retrieves just the PKs of a table, possibily filtering by fk field...
    public List<Integer> GetIDs(int fk) {
    		ServerRuntime runtime = new ServerRuntime("cayenne-MyDomain.xml");
    		ObjectContext context = runtime.getContext();
    		SQLTemplate select = new SQLTemplate(MyClass.class, 
    				"SELECT #result('" + MyClass.ID_PK_COLUMN + "' 'int') FROM MyClass WHERE MyFK=" + fk);
    		return context.performQuery(select);
    	}
    • Public Snippets
    • Channels Snippets