$ grep -r Tag: «скрипты»

-rw-r--r-- 1.6K Jan 10, 2013 · 87BA54F · ~2 min

PHP script for building all views in CouchDB

couchdb скрипты

I wrote this little script before New Year. It goes through all databases in CouchDB and builds all views one by one. Leaving it here.

<?php

            set_time_limit( 0 );

            // all dbs
            $ch = prepareCurlResource();
            curl_setopt( $ch, CURLOPT_URL, 'http://localhost:5984/_all_dbs' );
            $data = curl_exec( $ch );
            $dbs = json_decode( $data );

            foreach ( $dbs as $db ) {
                // skip _users and _replicator
                if ( substr( $db, 0, 1 ) == '_' )
                    continue;

                // getting all databases
                $chCC = prepareCurlResource();
                curl_setopt( $chCC, CURLOPT_URL, 'http://localhost:5984/' . $db . '/_all_docs?startkey="_design/"&endkey="_design0"&include_docs=true' );
                $data = json_decode( curl_exec( $chCC ) );

                if ( false === empty( $data->rows ) ) {
                    foreach( $data->rows as $design ) {

                        // creating views of design
                        if ( false === empty( $design->doc->views ) ) {
                            foreach( $design->doc->views as $viewName => $tmp ) {
                                echo 'Creating view: ' . $db . '/' . $design->id . '/_view/' . $viewName . "
";

                                $chCC = prepareCurlResource();
                                curl_setopt( $chCC, CURLOPT_URL, 'http://localhost:5984/' . $db . '/' . $design->id . '/_view/' . $viewName . '?limit=0' );
                                curl_exec( $chCC );
                            }
                        }
                    }
                }
            }

            function prepareCurlResource() {
            $ch = curl_init();
            curl_setopt( $ch, CURLOPT_PORT, 5984 );
            curl_setopt( $ch, CURLOPT_HEADER, false );
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
            curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-type: application/json' ) );

            return $ch;
            }
            
[↵] open page php-skript-dlya-sborki-vseh-vidov-v-couchdb.md
-rw-r--r-- 1.2K Mar 28, 2012 · 64007C0 · ~1 min

Script for pinning a block while scrolling

jQuery Sticky Scroller javascript скрипты полезное

I had wanted to make something like this for a long time, so that when the page is scrolled some block would scroll together with the page up to a certain point and then stick. Today I found a plugin called jQuery Sticky Scroller

You can download it here.

It is connected quite simply:

var scroller = new StickyScroller("#menu",
{
    start: 270,
    end: 50800,
    interval: 200,
    range: 100,
    margin: 0
});

As the parameter name suggests, when scrolling goes more than 270 pixels past the top edge of the page, the #menu element is fixed on the page, that is, it gets the CSS property position: fixed;. The end parameter is responsible for the lower bound of scroll tracking, in case the fixed element should not stay fixed all the time. The margin parameter defines how far from the top edge of the browser window the element will be positioned.

The plugin also has several public methods; I do not see much point in describing them here, the description is available on the plugin page.

[↵] open page skript-dlya-fiksirovaniya-bloka-pri-skrolle.md
-rw-r--r-- 6.9K Aug 15, 2011 · 1827A84 · ~6 min

Posting to Twitter via PHP

php twitter скрипты

Long meant to share my modest set of functions for posting tweets to Twitter. Maybe useful to someone — none of it came to me right away, especially the signature generation. Plus this is my attempt to lock into my head what I’ve learnt and coded. The best way to do that, I think, is to try to explain it to someone else :) Description and code below the cut.

[↵] open page otpravka-soobsheniy-v-twitter-cherez-php.md
-rw-r--r-- 5.4K Jul 13, 2011 · 7912FD1 · ~5 min

Resizing animated GIF images with Imagick

php imagick programming скрипты полезное

At work I ran into the need to process animated GIF avatars. The source images can be of any size, and they need to be downsized to a target size with cropping to a square. Below the cut — how we solved it.

[↵] open page resize-animirovannih-gif-izobrazheniy-s-imagick.md
-rw-r--r-- 434B May 13, 2011 · 2C445DF · ~1 min

Simple online TimeStamp converter

php javascript timestamp unix скрипты полезное

At work I occasionally have to look at some data from the database. Times we mostly store as TimeStamp (the number of seconds since the dawn of the Unix world — 1 January 1970).

A number like 1305233826 tells you nothing about what date it is. Writing the conversion in some script every time gets tedious, so I made an online converter. It shows the time in a human-readable form.

Enjoy. Online TimeStamp Converter

[↵] open page prostoy-online-timestamp-converter.md
makoni@arm1:~/blog$ cd .. // ↵ back to all posts