working on it ...

Filters

Explore Public Snippets

Sort by

Found 2.6M snippets

    public by Grizzlybeardesign modified yesterday at 7:01:11 PM  30  0  2  0

    Reverse Category Order

    Newest to Oldest to Oldest to Newest
    add_action( 'pre_get_posts', 'my_change_sort_order'); 
        function my_change_sort_order($query){
            if(is_archive()):
             //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type )
               //Set the order ASC or DESC
               $query->set( 'order', 'ASC' );
               //Set the orderby
               $query->set( 'orderby', 'date' );
            endif;    
        };

    public by electron modified Wednesday at 8:11:31 PM  63  0  2  0

    es6 async function

    template for async function es6 javascript js
    async function GetData() {
    	const resp = await axios.get('/url')
    	console.log(resp)
    }
    
    GetaData()

    public by DinhoPutz modified Oct 5, 2017  126  1  4  1

    Compactar Arquivos para Backup com Winrar

    REM Compactar arquivos para fazer backup. 
    REM Obs, é recomendável que os caminhos dos arquivos não contenham espaço. 
    
    
    REM Sobre a linha de comando 
    REM "RAR.exe a": o comando "a" adiciona arquivos no arquivo compacto que esta sendo criado.
    REM "-m5": nível de compressão, que vai de 0 à 5, sendo 5 o nível máximo de compressão.
    REM "-r": Para adicionar pastas e subpastas. 
    REM "-ag": É a marca de tempo, recomendável se for criar backups diário. 
    REM ">>": Gera o arquivo de log e a medida que o backup for sendo executado vai adicionandos novas linhas ao mesmo.
    
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo1.rar D:\Pasta1\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo2.rar D:\Pasta2\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo3.rar C:\Pasta3\ >> Saida.txt						

    public by Pallav modified Oct 2, 2017  257  0  4  0

    Predict

    // Enter here the actual content of the snippet.						
    
    
    foo.new$predictor[id] <- NA

    public by ikhwan88 modified Sep 29, 2017  117  0  3  0

    TABLE

    TABLE
    <table class="tabulka">
    <tbody><tr>
    <td colspan="2" class="hlavicka"><strong>Jennifer Lawrence measurements</strong></td>
    </tr>
    <tr>
    <td><span class="info">Body shape:</span></td>
    <td>Hourglass (<a href="http://www.bodymeasurements.org/female-body-shapes/" title="Guide for different female body types">explanation</a>)</td>
    </tr>
    <tr class="under">
    <td><span class="info">Dress size:</span></td>
    <td>6</td>
    </tr>
    <tr>
    <td><span class="info">Breasts-Waist-Hips:</span></td>
    <td>36-26-36 inches (91-66-91 cm)</td>
    </tr>
    <tr class="under">
    <td><span class="info">Shoe/Feet:</span></td>
    <td>10</td>
    </tr>
    <tr>
    <td><span class="info">Bra size:</span></td>
    <td>34B</td>
    </tr>
    <tr class="under">
    <td><span class="info">Cup:</span></td>
    <td>B</td>
    </tr>
    <tr>
    <td><span class="info">Height:</span></td>
    <td>5’8” (172 cm)</td>
    </tr>
    <tr class="under">
    <td><span class="info">Weight:</span></td>
    <td>137 lbs (62 kg)</td>
    </tr>
    <tr>
    <td><span class="info">Natural breasts or implants?</span></td>
    <td>Natural (<a href="http://www.bodymeasurements.org/real-vs-fake-breasts/" title="How to recognize fake breasts">how do we know this?</a>)</td>
    </tr>
    </tbody></table>				

    public by ronrihoo modified Sep 27, 2017  214  2  6  1

    Setting the libGDX Table background color

    A quick and less custom way.
    /*
     * It costs less to use a TextureRegion; however, to simplify the example,
     * a whole separate Texture is used here.
     */
    
    Table table;
    Texture whiteTexture;
    Sprite bgSprite;
    
    public void setBackgroundColor(int red, int green, int blue, int alpha) {
      // keep a reference to the Texture, so that it can be disposed later
    	whiteTexture = new Texture(Gdx.files.internal("white_color_texture.png"));
    	bgSprite = new Sprite(whiteTexture);
    	bgSprite.setColor(red/255f, green/255f, blue/255f, alpha/255f);
    	table.setBackground(new SpriteDrawable(bgSprite));
    }
    
    // ...
    
    public void disposeTexture() {
    	whiteTexture.dispose();
    }
    
    /*
     * An example of what's meant by "white_color_texture.png":
     * https://github.com/ronrihoo/libGDX-Table-Background-Color/blob/master/white_color_texture.png
     */

    public by kannuPriya modified Sep 19, 2017  301  2  5  0

    jQuery ready() Method

    The ready event occurs when the DOM (document object model) has been loaded. The ready() method specifies what happens when a ready event occurs.
    $(document).ready(function(){
       
    });

    public by ronrihoo modified Sep 15, 2017  252  0  6  0

    Example usage for the BackgroundColor class

    Companion usage example for the arbitrary libGDX Table BackgroundColor class.
    BackgroundColor backgroundColor = new BackgroundColor("white_color_texture.png");
    backgroundColor.setColor(2, 179, 228, 255); // r, g, b, a
    table.setBackground(backgroundColor);																														

    public by ronrihoo modified Sep 15, 2017  206  1  5  0

    Example helper class for GDXFacebook

    This helper class simplifies the usage of GDXFacebook in libGDX games and apps. (This is a backup to https://github.com/ronrihoo/GDX-Facebook-API-Helper and it's used in https://stackoverflow.com/a/46230835/6664817)
    // add package here
    
    import com.badlogic.gdx.Application;
    import com.badlogic.gdx.Gdx;
    import com.badlogic.gdx.utils.Array;
    import de.tomgrill.gdxfacebook.core.*;
    
    public class FacebookApi {
    
        private final static String CLASS_NAME = FacebookApi.class.getSimpleName();
        private final static String ERR_IN = "Error: in " + CLASS_NAME;
        private final static String EXC_IN = "Exception: in " + CLASS_NAME;
    
        private final static boolean VERBOSE_DEFAULT = true;
        private final static boolean DEBUG_DEFAULT = true;
    
        private boolean verbose;
        private boolean debug;
    
        private Array<String> permissions;
    
        private GDXFacebookConfig config;
        private GDXFacebook facebook;
        private GDXFacebookAccessToken token;
    
        /* if there's a class where credentials are stored or retrieved from,
         * then a constructor like this one could be used
         */ /*
        public FacebookApi() {
            this(Credentials.FB_API_ID);
        }
        /**/
    
        public FacebookApi(String appId) {
            this(appId, null, null);
        }
    
        /**
         *
         * @param appId The Facebook API ID is required.
         * @param prefFilename Optional (example: ".facebookSessionData").
         * @param apiVersion Optional. Graph API Version (default: v2.6).
         */
        public FacebookApi(String appId, String prefFilename, String apiVersion) {
            init(appId, prefFilename, apiVersion, DEBUG_DEFAULT);
        }
    
        private void init(String appId, String prefFilename,
                          String apiVersion, boolean debug) {
            setVerbose(VERBOSE_DEFAULT);
            setDebug(debug);
            if (appId != null) {
                setAppId(appId);
            } else {
                try {
                    throw new RuntimeException(EXC_IN +
                            ".init(...): appId is null. Has it been passed correctly?");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (prefFilename != null)
                setPrefFilename(prefFilename);
            if (apiVersion != null)
                setGraphApiVersion(apiVersion);
            initPermissionsArray();
            installGdxFacebookInstance();
            setGdxFacebookInstance();
            addBasicPermissions();
        }
    
        private void setGdxDebug(boolean debug) {
            debugLog("setGdxDebug(boolean debug)");
            if (debug)
                Gdx.app.setLogLevel(Application.LOG_DEBUG);
            // TODO: turn it off when debug == false
        }
    
        private void instantiateConfig() {
            debugLog("instantiateConfig()");
            config = new GDXFacebookConfig();
        }
    
        private boolean verifyConfig() {
            debugLog("verifyConfig()");
            if (config == null) {
                try {
                    instantiateConfig();
                }
                catch (Exception e) {
                    System.out.println(EXC_IN + ".verifyConfig(): \n" + e);
                    return false;
                }
            }
            return true;
        }
    
        private void setAppId(String appId) {
            debugLog("setAppId(String appId)");
            if (verifyConfig())
                config.APP_ID = appId;
        }
    
        private void setPrefFilename(String filename) {
            debugLog("setPrefFilename(String filename)");
            if (verifyConfig())
                config.PREF_FILENAME = filename;
        }
    
        private void setGraphApiVersion(String version) {
            debugLog("setGraphApiVersion(String version)");
            if (verifyConfig())
                config.GRAPH_API_VERSION = version;
        }
    
        private void installGdxFacebookInstance() {
            debugLog("installGdxFacebookInstance()");
            if (verifyConfig())
                facebook = GDXFacebookSystem.install(config);
        }
    
        /**
         * No parameters, as it is handled by GDXFacebookSystem
         */
        public void setGdxFacebookInstance() {
            debugLog("setGdxFacebookInstance()");
            if (facebook != null)
                facebook = GDXFacebookSystem.getFacebook();
        }
    
        /**
         *
         * @return GDXFacebook object.
         */
        public GDXFacebook getGdxFacebookInstance() {
            debugLog("getGdxFacebookInstance()");
            return facebook;
        }
    
        private void initPermissionsArray() {
            debugLog("initPermissionsArray()");
            permissions = new Array<String>();
        }
    
        private void addBasicPermissions() {
            debugLog("addBasicPermissions()");
            permissions.add("email");
            permissions.add("public_profile");
            permissions.add("user_friends");
        }
    
        public void addPermission(String permission) {
            debugLog("addPermission(String)");
            if (permissions != null)
                permissions.add(permission);
            else
                System.out.println(ERR_IN + ": permissions array is null");
        }
    
        /**
         * Basic sign-in with read-mode
         */
        public void signIn() {
            debugLog("signIn()");
            signIn(SignInMode.READ);
        }
    
        public void signIn(SignInMode signInMode) {
            debugLog("signIn(SignInMode)");
            if (facebook != null) {
                if (permissions == null) {
                    addBasicPermissions();
                    debug(CLASS_NAME +
                            ": returned to signIn(SignInMode) from addBasicPermissions()");
                }
                facebook.signIn(signInMode, permissions, new GDXFacebookCallback<SignInResult>() {
    
                    @Override
                    public void onSuccess(SignInResult result) {
                        if (verbose)
                            System.out.println("Successfully signed in Facebook.");
                        token = result.getAccessToken();
                        debug(CLASS_NAME + ".signIn() succeeded.");
                        debug(CLASS_NAME + ": accessToken is " + token);
                    }
    
                    @Override
                    public void onError(GDXFacebookError error) {
                        if (debug)
                            System.out.println(ERR_IN + ".signIn(): " +
                                    error.getErrorMessage());
                        debug("signIn() invoked by GDXFacebook instance, facebook, in " +
                                CLASS_NAME + " faced an error.");
                    }
    
                    @Override
                    public void onCancel() {
                        // When the user cancels the login process
                        debug("signIn() invoked by GDXFacebook instance, facebook, in " +
                                CLASS_NAME + " canceled.");
                    }
    
                    @Override
                    public void onFail(Throwable t) {
                        // When the login fails
                        debug("signIn() invoked by GDXFacebook instance, facebook, in " +
                                CLASS_NAME + " failed.");
                    }
                });
            } else {
                debug(ERR_IN + ".signIn(): " +
                        "GDXFacebook instance, facebook, is null.");
            }
        }
    
        public void signOut() {
            debug(CLASS_NAME + ".signOut()");
            facebook.signOut();
        }
    
        protected void setVerbose(boolean verbose) {
            this.verbose = verbose;
        }
    
        protected void setDebug(boolean debug) {
            this.debug = debug;
            setGdxDebug(debug);
        }
    
        private void debug(String msg) {
            if (debug)
                System.out.println(msg);
        }
    
        private void debugLog(String methodName) {
            if (verbose)
                debug(CLASS_NAME + "." + methodName);
        }
    
    }

    public by 04pallav modified Sep 13, 2017  93  2  1  0

    hrbi schema

    hrbi schema: new_gist_file_0.sql
    This table contains the start date for diferent employees.
    
    Each row represents a unique employee and when he joined.
    
    empl_id       
    empl_user_id   --PALLANAN
    dd_dt -- starting date of each employee 
    job_lvl_nm -- Level of job  I am level 4
    reports_to_level3_login = 'REYNOLM'    # director Hr filter Mike Reynold's group
    person_org_nm
    dept_org_level1
    loc_cntry_nm  ---  Name of the country where employe is working 'USA'
    person_org_nm ---- has only three values Employee, NULL contingent worker.
    
    
    count
    3566985
    ############################################################################
    hrbi_monthly_snapshot
    
    
    For each month this table contains a snapshot for an employee. A particular employe can get promoted so data changes. Historical is preserved.
    can be used to get Active headcount
    
    ##########################################################################
    hrbi_wfm_terms
    
    termination data similar to start date data.
    
    
    #Reynoldson Org STARTS, HC, TERMS query, can easily switch out the reports to for other groups,
    SELECT c.month, c.year, c.job_lvl_nm, starts, active_hc, terms  FROM
    (SELECT a.month, a.year, a.job_lvl_nm, starts, active_hc FROM
    ((SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year
          , count(*) as starts
          , job_lvl_nm
           FROM hrbi.hrbi_wfm_starts  WHERE reports_to_level3_login = 'REYNOLM' GROUP BY  month, year, job_lvl_nm) a
    JOIN
    (SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year, count(*) as active_hc, job_lvl_nm FROM hrbi.hrbi_monthly_snapshot
           WHERE reports_to_level3_login = 'REYNOLM' GROUP BY  month, year, job_lvl_nm) b
    ON a.month = b.month AND a.job_lvl_nm = b.job_lvl_nm AND a.year = b.year)) c
    
    JOIN (SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year
          ,job_lvl_nm
          , count(*) as terms
           FROM hrbi.hrbi_wfm_terms  WHERE reports_to_level3_login = 'REYNOLM' GROUP BY  month, year, job_lvl_nm) d
     ON c.month = d.month AND c.job_lvl_nm = d.job_lvl_nm AND c.year = d.year
     
     
     
     ############################################################## Fulfillment centers starts, terms, active headcount
     
     
     SELECT c.month, c.year, c.country, starts, active_hc, terms FROM (SELECT a.month, a.year, a.country, starts, active_hc FROM (SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year
          ,loc_cntry_nm as country
          , count(*) as starts
           FROM hrbi.hrbi_wfm_starts  WHERE country = 'USA'  AND person_org_nm = 'Employee' AND job_lvl_nm IN ('1', '2', '3') AND dept_org_level1 = 'Ops & Cust Svc' GROUP BY country, month, year ) a
          JOIN
          (SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year
     ,loc_cntry_nm as country
     , count(*) as active_hc
     FROM hrbi.hrbi_monthly_snapshot WHERE country = 'USA'  AND person_org_nm = 'Employee' AND job_lvl_nm IN ('1', '2', '3') AND dept_org_level1 = 'Ops & Cust Svc' GROUP BY country, month, year) b
      ON a.month = b.month AND a.country = b.country AND a.year = b.year) c
      JOIN (SELECT date_part('month', dd_dt) as month
          ,date_part('year', dd_dt) as year
          ,loc_cntry_nm as country
          , count(*) as terms
           FROM hrbi.hrbi_wfm_terms  WHERE country = 'USA'  AND person_org_nm = 'Employee' AND job_lvl_nm IN ('1', '2', '3') AND dept_org_level1 = 'Ops & Cust Svc' GROUP BY country, month, year) d
      ON c.month = d.month AND c.country = d.country AND c.year = d.year
    
    
    
    
    
    
    
    
    
    
    
    
    
    • Public Snippets
    • Channels Snippets