text:
#ifndef __SUNVOX_H__
#define __SUNVOX_H__

#define NOTECMD_NOTE_OFF	128
#define NOTECMD_ALL_NOTES_OFF	129 /* notes of all synths off */
#define NOTECMD_CLEAN_SYNTHS	130 /* stop and clean all synths */
#define NOTECMD_STOP		131
#define NOTECMD_PLAY		132

//sv_send_event() parameters:
//  slot;
//  channel_num: from 0 to 7;
//  note: 0 - nothing; 1..127 - note num; 128 - note off; 129, 130... - see NOTECMD_xxx defines;
//  vel: velocity 1..129; 0 - default;
//  module: 0 - nothing; 1..255 - module number;
//  ctl: CCXX. CC - number of controller. XX - std effect;
//  ctl_val: value of controller.

typedef struct
{
    unsigned char	note;           //0 - nothing; 1..127 - note num; 128 - note off; 129, 130... - see NOTECMD_xxx defines
    unsigned char       vel;            //Velocity 1..129; 0 - default
    unsigned char       module;         //0 - nothing; 1..255 - module number
    unsigned char       nothing;
    unsigned short      ctl;            //CCXX. CC - number of controller. XX - std effect
    unsigned short      ctl_val;        //Value of controller
} sunvox_note;

#define SV_INIT_FLAG_NO_DEBUG_OUTPUT 		( 1 << 0 )
#define SV_INIT_FLAG_USER_AUDIO_CALLBACK 	( 1 << 1 ) /* Interaction with sound card is on the user side */
#define SV_INIT_FLAG_AUDIO_INT16 		( 1 << 2 )
#define SV_INIT_FLAG_AUDIO_FLOAT32 		( 1 << 3 )
#define SV_INIT_FLAG_ONE_THREAD			( 1 << 4 ) /* Audio callback and song modification functions are in single thread */

#define SV_MODULE_FLAG_EXISTS 1
#define SV_MODULE_FLAG_EFFECT 2
#define SV_MODULE_INPUTS_OFF 16
#define SV_MODULE_INPUTS_MASK ( 255 << SV_MODULE_INPUTS_OFF )
#define SV_MODULE_OUTPUTS_OFF ( 16 + 8 )
#define SV_MODULE_OUTPUTS_MASK ( 255 << SV_MODULE_OUTPUTS_OFF )

#define SV_STYPE_INT16 0
#define SV_STYPE_INT32 1
#define SV_STYPE_FLOAT32 2
#define SV_STYPE_FLOAT64 3

#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
    #define WIN
    #define LIBNAME "sunvox.dll"
#endif
#if defined(__APPLE__)
    #define OSX
    #define LIBNAME "sunvox.dylib"
#endif
#if defined(__linux__) || defined(linux)
    #define LINUX
    #define LIBNAME "./sunvox.so"
#endif
#if defined(OSX) || defined(LINUX)
    #define UNIX
#endif

#ifdef WIN
    #define SUNVOX_FN_ATTR __attribute__((stdcall))
#endif
#ifndef SUNVOX_FN_ATTR
    #define SUNVOX_FN_ATTR /**/
#endif

//sv_audio_callback() - get the next piece of SunVox audio.
//buf - destination buffer of type signed short (if SV_INIT_FLAG_AUDIO_INT16 used in sv_init())
//      or float (if SV_INIT_FLAG_AUDIO_FLOAT32 used in sv_init());
//	stereo data will be interleaved in this buffer: LRLR... ; where the LR is the one frame;
//frames - number of frames in destination buffer;
//latency - audio latency (in frames);
//out_time - output time (in ticks).
typedef int (*tsv_audio_callback)( void* buf, int frames, int latency, unsigned int out_time ) SUNVOX_FN_ATTR;
typedef int (*tsv_open_slot)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_close_slot)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_lock_slot)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_unlock_slot)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_init)( const char* dev, int freq, int channels, int flags ) SUNVOX_FN_ATTR;
typedef int (*tsv_deinit)( void ) SUNVOX_FN_ATTR;
//sv_get_sample_type() - get internal sample type of the SunVox engine. Return value: one of the SV_STYPE_xxx defines.
//Use it to get the scope buffer type from get_module_scope() function.
typedef int (*tsv_get_sample_type)( void ) SUNVOX_FN_ATTR;
typedef int (*tsv_load)( int slot, const char* name ) SUNVOX_FN_ATTR;
typedef int (*tsv_load_from_memory)( int slot, void* data, unsigned int data_size ) SUNVOX_FN_ATTR;
typedef int (*tsv_play)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_play_from_beginning)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_stop)( int slot ) SUNVOX_FN_ATTR;
//autostop values: 0 - disable autostop; 1 - enable autostop.
//When disabled, song is playing infinitely in the loop.
typedef int (*tsv_set_autostop)( int slot, int autostop ) SUNVOX_FN_ATTR;
//sv_end_of_song() return values: 0 - song is playing now; 1 - stopped.
typedef int (*tsv_end_of_song)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_rewind)( int slot, int t ) SUNVOX_FN_ATTR;
typedef int (*tsv_volume)( int slot, int vol ) SUNVOX_FN_ATTR;
typedef int (*tsv_send_event)( int slot, int channel_num, int note, int vel, int module, int ctl, int ctl_val ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_current_line)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_current_signal_level)( int slot, int channel ) SUNVOX_FN_ATTR; //From 0 to 255
typedef const char* (*tsv_get_song_name)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_song_bpm)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_song_tpl)( int slot ) SUNVOX_FN_ATTR;
//Frame is one discrete of the sound. Sampling frequency 44100 Hz means, that you hear 44100 frames per second.
typedef unsigned int (*tsv_get_song_length_frames)( int slot ) SUNVOX_FN_ATTR;
typedef unsigned int (*tsv_get_song_length_lines)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_number_of_modules)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_module_flags)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef int* (*tsv_get_module_inputs)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef int* (*tsv_get_module_outputs)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef const char* (*tsv_get_module_name)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef unsigned int (*tsv_get_module_xy)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_module_color)( int slot, int mod_num ) SUNVOX_FN_ATTR;
typedef void* (*tsv_get_module_scope)( int slot, int mod_num, int channel, int* offset, int* buffer_size ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_number_of_patterns)( int slot ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_pattern_x)( int slot, int pat_num ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_pattern_y)( int slot, int pat_num ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_pattern_tracks)( int slot, int pat_num ) SUNVOX_FN_ATTR;
typedef int (*tsv_get_pattern_lines)( int slot, int pat_num ) SUNVOX_FN_ATTR;
typedef sunvox_note* (*tsv_get_pattern_data)( int slot, int pat_num ) SUNVOX_FN_ATTR;
typedef int (*tsv_pattern_mute)( int slot, int pat_num, int mute ) SUNVOX_FN_ATTR; //Use it with sv_lock_slot() and sv_unlock_slot()
//SunVox engine uses its own time space, measured in ticks.
//Use sv_get_ticks() to get current tick counter (from 0 to 0xFFFFFFFF).
//Use sv_get_ticks_per_second() to get the number of SunVox ticks per second.
typedef unsigned int (*tsv_get_ticks)( void ) SUNVOX_FN_ATTR;
typedef unsigned int (*tsv_get_ticks_per_second)( void ) SUNVOX_FN_ATTR;

#ifdef SUNVOX_MAIN

#ifdef WIN
#define IMPORT( Handle, Type, Function, Store ) \
    { \
	Store = (Type)GetProcAddress( Handle, Function ); \
	if( Store == 0 ) { fn_not_found = Function; break; } \
    }
#define ERROR_MSG( msg ) MessageBox( 0, TEXT("msg"), TEXT("Error"), MB_OK );
#endif

#ifdef UNIX
#define IMPORT( Handle, Type, Function, Store ) \
    { \
	Store = (Type)dlsym( Handle, Function ); \
	if( Store == 0 ) { fn_not_found = Function; break; } \
    }
#define ERROR_MSG( msg ) printf( "ERROR: %s\n", msg );
#endif

tsv_audio_callback sv_audio_callback = 0;
tsv_open_slot sv_open_slot = 0;
tsv_close_slot sv_close_slot = 0;
tsv_lock_slot sv_lock_slot = 0;
tsv_unlock_slot sv_unlock_slot = 0;
tsv_init sv_init = 0;
tsv_deinit sv_deinit = 0;
tsv_get_sample_type sv_get_sample_type = 0;
tsv_load sv_load = 0;
tsv_load_from_memory sv_load_from_memory = 0;
tsv_play sv_play = 0;
tsv_play_from_beginning sv_play_from_beginning = 0;
tsv_stop sv_stop = 0;
tsv_set_autostop sv_set_autostop = 0;
tsv_end_of_song sv_end_of_song = 0;
tsv_rewind sv_rewind = 0;
tsv_volume sv_volume = 0;
tsv_send_event sv_send_event = 0;
tsv_get_current_line sv_get_current_line = 0;
tsv_get_current_signal_level sv_get_current_signal_level = 0;
tsv_get_song_name sv_get_song_name = 0;
tsv_get_song_bpm sv_get_song_bpm = 0;
tsv_get_song_tpl sv_get_song_tpl = 0;
tsv_get_song_length_frames sv_get_song_length_frames = 0;
tsv_get_song_length_lines sv_get_song_length_lines = 0;
tsv_get_number_of_modules sv_get_number_of_modules = 0;
tsv_get_module_flags sv_get_module_flags = 0;
tsv_get_module_inputs sv_get_module_inputs = 0;
tsv_get_module_outputs sv_get_module_outputs = 0;
tsv_get_module_name sv_get_module_name = 0;
tsv_get_module_xy sv_get_module_xy = 0;
tsv_get_module_color sv_get_module_color = 0;
tsv_get_module_scope sv_get_module_scope = 0;
tsv_get_number_of_patterns sv_get_number_of_patterns = 0;
tsv_get_pattern_x sv_get_pattern_x = 0;
tsv_get_pattern_y sv_get_pattern_y = 0;
tsv_get_pattern_tracks sv_get_pattern_tracks = 0;
tsv_get_pattern_lines sv_get_pattern_lines = 0;
tsv_get_pattern_data sv_get_pattern_data = 0;
tsv_pattern_mute sv_pattern_mute = 0;
tsv_get_ticks sv_get_ticks = 0;
tsv_get_ticks_per_second sv_get_ticks_per_second = 0;

#ifdef UNIX
    void* g_sv_dll = 0;
#endif

#ifdef WIN
    HMODULE g_sv_dll = 0;
#endif

int sv_load_dll( void )
{
#ifdef WIN
    g_sv_dll = LoadLibrary( TEXT(LIBNAME) );
    if( g_sv_dll == 0 )
    {
        ERROR_MSG( "sunvox.dll not found" );
        return 1;
    }
#endif
#ifdef UNIX
    g_sv_dll = dlopen( LIBNAME, RTLD_NOW );
    if( g_sv_dll == 0 )
    {
	printf( "%s\n", dlerror() );
        return 1;
    }
#endif
    const char* fn_not_found = 0;
    while( 1 )
    {
	IMPORT( g_sv_dll, tsv_audio_callback, "sv_audio_callback", sv_audio_callback );
	IMPORT( g_sv_dll, tsv_open_slot, "sv_open_slot", sv_open_slot );
	IMPORT( g_sv_dll, tsv_close_slot, "sv_close_slot", sv_close_slot );
	IMPORT( g_sv_dll, tsv_lock_slot, "sv_lock_slot", sv_lock_slot );
	IMPORT( g_sv_dll, tsv_unlock_slot, "sv_unlock_slot", sv_unlock_slot );
	IMPORT( g_sv_dll, tsv_init, "sv_init", sv_init );
	IMPORT( g_sv_dll, tsv_deinit, "sv_deinit", sv_deinit );
	IMPORT( g_sv_dll, tsv_get_sample_type, "sv_get_sample_type", sv_get_sample_type );
	IMPORT( g_sv_dll, tsv_load, "sv_load", sv_load );
	IMPORT( g_sv_dll, tsv_load_from_memory, "sv_load_from_memory", sv_load_from_memory );
	IMPORT( g_sv_dll, tsv_play, "sv_play", sv_play );
	IMPORT( g_sv_dll, tsv_play_from_beginning, "sv_play_from_beginning", sv_play_from_beginning );
	IMPORT( g_sv_dll, tsv_stop, "sv_stop", sv_stop );
	IMPORT( g_sv_dll, tsv_set_autostop, "sv_set_autostop", sv_set_autostop );
	IMPORT( g_sv_dll, tsv_end_of_song, "sv_end_of_song", sv_end_of_song );
	IMPORT( g_sv_dll, tsv_rewind, "sv_rewind", sv_rewind );
	IMPORT( g_sv_dll, tsv_volume, "sv_volume", sv_volume );
	IMPORT( g_sv_dll, tsv_send_event, "sv_send_event", sv_send_event );
	IMPORT( g_sv_dll, tsv_get_current_line, "sv_get_current_line", sv_get_current_line );
	IMPORT( g_sv_dll, tsv_get_current_signal_level, "sv_get_current_signal_level", sv_get_current_signal_level );
	IMPORT( g_sv_dll, tsv_get_song_name, "sv_get_song_name", sv_get_song_name );
	IMPORT( g_sv_dll, tsv_get_song_bpm, "sv_get_song_bpm", sv_get_song_bpm );
	IMPORT( g_sv_dll, tsv_get_song_tpl, "sv_get_song_tpl", sv_get_song_tpl );
	IMPORT( g_sv_dll, tsv_get_song_length_frames, "sv_get_song_length_frames", sv_get_song_length_frames );
	IMPORT( g_sv_dll, tsv_get_song_length_lines, "sv_get_song_length_lines", sv_get_song_length_lines );
	IMPORT( g_sv_dll, tsv_get_number_of_modules, "sv_get_number_of_modules", sv_get_number_of_modules );
	IMPORT( g_sv_dll, tsv_get_module_flags, "sv_get_module_flags", sv_get_module_flags );
	IMPORT( g_sv_dll, tsv_get_module_inputs, "sv_get_module_inputs", sv_get_module_inputs );
	IMPORT( g_sv_dll, tsv_get_module_outputs, "sv_get_module_outputs", sv_get_module_outputs );
	IMPORT( g_sv_dll, tsv_get_module_name, "sv_get_module_name", sv_get_module_name );
	IMPORT( g_sv_dll, tsv_get_module_xy, "sv_get_module_xy", sv_get_module_xy );
	IMPORT( g_sv_dll, tsv_get_module_color, "sv_get_module_color", sv_get_module_color );
	IMPORT( g_sv_dll, tsv_get_module_scope, "sv_get_module_scope", sv_get_module_scope );
	IMPORT( g_sv_dll, tsv_get_number_of_patterns, "sv_get_number_of_patterns", sv_get_number_of_patterns );
	IMPORT( g_sv_dll, tsv_get_pattern_x, "sv_get_pattern_x", sv_get_pattern_x );
	IMPORT( g_sv_dll, tsv_get_pattern_y, "sv_get_pattern_y", sv_get_pattern_y );
	IMPORT( g_sv_dll, tsv_get_pattern_tracks, "sv_get_pattern_tracks", sv_get_pattern_tracks );
	IMPORT( g_sv_dll, tsv_get_pattern_lines, "sv_get_pattern_lines", sv_get_pattern_lines );
	IMPORT( g_sv_dll, tsv_get_pattern_data, "sv_get_pattern_data", sv_get_pattern_data );
	IMPORT( g_sv_dll, tsv_pattern_mute, "sv_pattern_mute", sv_pattern_mute );
	IMPORT( g_sv_dll, tsv_get_ticks, "sv_get_ticks", sv_get_ticks );
	IMPORT( g_sv_dll, tsv_get_ticks_per_second, "sv_get_ticks_per_second", sv_get_ticks_per_second );
	break;
    }
    if( fn_not_found )
    {
	char ts[ 256 ];
	sprintf( ts, "sunvox lib: %s() not found", fn_not_found );
	ERROR_MSG( ts );
	return -1;
    }

    return 0;
}

int sv_unload_dll( void )
{
#ifdef UNIX
    if( g_sv_dll ) dlclose( g_sv_dll );
#endif
    return 0;
}

#endif

#endif


text:
import logging; logger = logging.getLogger("morse." + __name__)
import bge
import math
import mathutils
import morse.core.sensor

"""
Important note:

    The 'logger.debug' instructions take some processor work, even if they are
    not displayed. For this reason, it is best to comment out these lines in
    the 'default_action' method.
"""

class ImuClass(morse.core.sensor.MorseSensorClass):
    """ IMU sensor """

    def __init__(self, obj, parent=None):
        """ Constructor method.

        Receives the reference to the Blender object.
        The second parameter should be the name of the object's parent.
        """
        logger.info('%s initialization' % obj.name)
        # Call the constructor of the parent class
        super(self.__class__, self).__init__(obj, parent)

        #logger.setLevel(logging.DEBUG)

        # The robot needs a physics controller!
        # Since the imu does not have physics,
        self.has_physics = bool(self.robot_parent.blender_obj.getPhysicsId())

        if not self.has_physics:
            logger.warning("The robot doesn't have a physics controller," \
                           "falling back to simple IMU sensor.")

        if self.has_physics:
            # make new references to the robot velocities and use those.
            self.robot_w = self.robot_parent.blender_obj.localAngularVelocity
            self.robot_vel = self.robot_parent.blender_obj.worldLinearVelocity
        else:
            # reference to sensor position
            self.pos = self.blender_obj.worldPosition
            # previous position
            self.pp = self.pos.copy()
            # previous attitude euler angles as vector
            self.patt = mathutils.Vector(self.position_3d.euler)

        # previous linear velocity
        self.plv = mathutils.Vector((0.0, 0.0, 0.0))
        # previous angular velocity
        self.pav = mathutils.Vector((0.0, 0.0, 0.0))

        # get gravity from scene?
        #g = bpy.data.scenes[0].game_settings.physics_gravity
        g = 9.81
        self.gravity = mathutils.Vector((0.0, 0.0, g))

        # get the transformation from robot to sensor frame
        (loc, rot, scale) = self.robot_parent.position_3d.transformation3d_with(self.position_3d).matrix.decompose()
        logger.debug("body2imu rotation RPY [% .3f % .3f % .3f]" % tuple(math.degrees(a) for a in rot.to_euler()))
        logger.debug("body2imu translation [% .3f % .3f % .3f]" % tuple(loc))
        # store body to imu rotation and translation
        self.rot_b2i = rot
        self.trans_b2i = loc

        if (loc.length > 0.01):
            self.compute_offset_acceleration = True
        else:
            self.compute_offset_acceleration = False

        # reference for rotating world frame to imu frame
        self.rot_w2i = self.blender_obj.worldOrientation

        self.local_data['angular_velocity'] = [0.0, 0.0, 0.0]
        self.local_data['linear_acceleration'] = [0.0, 0.0, 0.0]

        logger.info("IMU Component initialized, runs at %.2f Hz ", self.frequency)

    def sim_imu_simple(self):
        """
        Simulate angular velocity and linear acceleration measurements via simple differences.
        """

        # Compute the differences with the previous loop
        #dp = self.pos - self.pp
        #deuler = mathutils.Vector(self.position_3d.euler - self.peuler)

        # linear and angular velocities
        lin_vel = (self.pos - self.pp) * self.frequency
        att = mathutils.Vector(self.position_3d.euler)
        ang_vel = (att - self.patt) * self.frequency

        # linear acceleration in imu frame
        dv_imu = self.rot_w2i.transposed() * (lin_vel - self.plv) * self.frequency

        # measurement includes gravity and acceleration
        accel_meas = dv_imu + self.rot_w2i.transposed() * self.gravity

        # save current position and attitude for next step
        self.pp = self.pos.copy()
        self.peuler = att
        # save velocity for next step
        self.plv = lin_vel
        self.pav = ang_vel

        return (ang_vel, accel_meas)

    def sim_imu_with_physics(self):
        """
        Simulate angular velocity and linear acceleration measurements using the physics of the robot.
        """

        # rot_b2i rotates body frame to imu frame
        # take the inverse rotation to transform a vector from body to imu
        rates = self.rot_b2i.conjugated() * self.robot_w
        #logger.debug("rates in robot frame (% .4f, % .4f, % .4f)", self.robot_w[0], self.robot_w[1], self.robot_w[2])
        #logger.debug("rates in imu frame   (% .4f, % .4f, % .4f)", rates[0], rates[1], rates[2])

        # differentiate linear velocity in world (inertial) frame
        # and rotate to imu frame
        dv_imu = self.rot_w2i.transposed() * (self.robot_vel - self.plv) * self.frequency
        #logger.debug("velocity_dot in imu frame (% .4f, % .4f, % .4f)", dv_imu[0], dv_imu[1], dv_imu[2])

        # rotate acceleration due to gravity into imu frame
        g_imu = self.rot_w2i.transposed() * self.gravity

        # measurement includes gravity and acceleration
        accel_meas = dv_imu + g_imu

        if self.compute_offset_acceleration:
            # acceleration due to rotation (centripetal)
            # is zero if imu is mounted in robot center (assumed axis of rotation)
            a_centripetal = self.rot_b2i.conjugated() * rates.cross(rates.cross(self.trans_b2i))
            #logger.debug("centripetal acceleration (% .4f, % .4f, % .4f)", a_rot[0], a_rot[1], a_rot[2])

            # linear acceleration due to angular acceleration
            a_alpha = self.rot_b2i.conjugated() * (self.robot_w - self.pav).cross(self.trans_b2i) * self.frequency

            # final measurement includes acceleration due to rotation center not in IMU
            accel_meas += a_centripetal + a_alpha

        # save velocity for next step
        self.plv = self.robot_vel.copy()
        self.pav = self.robot_w.copy()

        return (rates, accel_meas)

    def default_action(self):
        """
        Get the speed and acceleration of the robot and transform it into the imu frame
        """
        if self.has_physics:
            (rates, accel) = self.sim_imu_with_physics()
        else:
            (rates, accel) = self.sim_imu_simple()

        # Store the important data
        self.local_data['angular_velocity'] = rates
        self.local_data['linear_acceleration'] = accel

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <integer name="page_font_size_default">18</integer>

    <integer name="div_width_max">420</integer>
    <integer name="div_start_percent">30</integer>

</resources>


text:
FactoryGirl.define do
  factory :alliance do

  end
end


text:
<?php

namespace Presta\SitemapBundle\Service;

use Presta\SitemapBundle\DependencyInjection\Configuration;
use Presta\SitemapBundle\Sitemap\DumpingUrlset;
use Presta\SitemapBundle\Sitemap\Urlset;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
 * Generator that dump sitemaps to files.
 */
class Dumper extends AbstractGenerator implements DumperInterface
{
    /**
     * Path to folder where temporary files will be created
     * @var string
     */
    protected $tmpFolder;

    /**
     * Base URL where dumped sitemap files can be accessed (we can't guess that from console)
     * @var string
     */
    protected $baseUrl;

    /**
     * @var Filesystem
     */
    protected $filesystem;

    /**
     * @var string
     */
    protected $sitemapFilePrefix;

    /**
     * @param EventDispatcherInterface   $dispatcher Symfony's EventDispatcher
     * @param Filesystem                 $filesystem Symfony's Filesystem
     * @param string                     $sitemapFilePrefix
     * @param int|null                   $itemsBySet
     * @param UrlGeneratorInterface|null $urlGenerator
     */
    public function __construct(
        EventDispatcherInterface $dispatcher,
        Filesystem $filesystem,
        string $sitemapFilePrefix = Configuration::DEFAULT_FILENAME,
        int $itemsBySet = null,
        UrlGeneratorInterface $urlGenerator = null
    ) {
        parent::__construct($dispatcher, $itemsBySet, $urlGenerator);

        $this->filesystem = $filesystem;
        $this->sitemapFilePrefix = $sitemapFilePrefix;
    }

    /**
     * @inheritdoc
     */
    public function dump(string $targetDir, string $host, string $section = null, array $options = [])
    {
        /** @var array{gzip: bool} $options */
        $options = array_merge(['gzip' => false], $options);

        $this->baseUrl = rtrim($host, '/') . '/';
        // we should prepare temp folder each time, because dump may be called several times (with different sections)
        // and activate command below removes temp folder
        $this->prepareTempFolder();

        $filenames = [];

        try {
            $this->populate($section);

            // if no urlset wasn't created during populating
            // it means no URLs were added to the sitemap
            if (!count($this->urlsets)) {
                $this->cleanup();

                return false;
            }

            foreach ($this->urlsets as $urlset) {
                if ($urlset instanceof DumpingUrlset) {
                    $urlset->save($this->tmpFolder, $options['gzip']);
                }
                $filenames[] = basename($urlset->getLoc());
            }

            if (null !== $section) {
                // Load current SitemapIndex file and add all sitemaps except those,
                // matching section currently being regenerated to root
                $index = $this->loadCurrentSitemapIndex($targetDir . '/' . $this->sitemapFilePrefix . '.xml');
                foreach ($index as $key => $urlset) {
                    // cut possible _X, to compare base section name
                    $baseKey = preg_replace('/(.*?)(_\d+)?/', '\1', $key);
                    if ($baseKey !== $section) {
                        // we add them to root only, if we add them to $this->urlset
                        // deleteExistingSitemaps() will delete matching files, which we don't want
                        $this->getRoot()->addSitemap($urlset);
                    }
                }
            }

            file_put_contents($this->tmpFolder . '/' . $this->sitemapFilePrefix . '.xml', $this->getRoot()->toXml());
            $filenames[] = $this->sitemapFilePrefix . '.xml';

            // if we came to this point - we can activate new files
            // if we fail on exception eariler - old files will stay making Google happy
            $this->activate($targetDir);
        } finally {
            $this->cleanup();
        }

        return $filenames;
    }

    /**
     * Prepares temp folder for storing sitemap files
     *
     * @return void
     */
    protected function prepareTempFolder(): void
    {
        $this->tmpFolder = sys_get_temp_dir() . '/PrestaSitemaps-' . uniqid();
        $this->filesystem->mkdir($this->tmpFolder);
    }

    /**
     * Cleans up temporary files
     *
     * @return void
     */
    protected function cleanup(): void
    {
        $this->filesystem->remove($this->tmpFolder);
        $this->root = null;
        $this->urlsets = [];
    }

    /**
     * Loads sitemap index XML file and returns array of Urlset objects
     *
     * @param string $filename
     *
     * @return Urlset[]
     * @throws \InvalidArgumentException
     */
    protected function loadCurrentSitemapIndex(string $filename): array
    {
        if (!file_exists($filename)) {
            return [];
        }

        $urlsets = [];
        $index = simplexml_load_file($filename);
        if ($index === false) {
            throw new \InvalidArgumentException(
                "Sitemaps in $filename doesn't contain valid XML."
            );
        }

        foreach ($index->children() as $child) {
            /** @var $child \SimpleXMLElement */
            if ($child->getName() === 'sitemap') {
                if (!isset($child->loc)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'loc' attribute"
                    );
                }
                preg_match(
                    '/^' . preg_quote($this->sitemapFilePrefix) . '\.(.+)\.xml(\.gz)?$/',
                    basename($child->loc),
                    $matches
                ); // cut .xml|.xml.gz and check gz files
                $basename = $matches[1];
                $gzOption = isset($matches[2]);

                if (!isset($child->lastmod)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'lastmod' attribute"
                    );
                }
                $lastmod = new \DateTimeImmutable($child->lastmod);
                $urlsets[$basename] = $this->newUrlset($basename, $lastmod, $gzOption);
            }
        }

        return $urlsets;
    }

    /**
     * Moves sitemaps created in a temporary folder to their real location
     *
     * @param string $targetDir Directory to move created sitemaps to
     *
     * @throws \RuntimeException
     */
    protected function activate(string $targetDir): void
    {
        if (!is_dir($targetDir)) {
            mkdir($targetDir, 0777, true);
        }

        if (!is_writable($targetDir)) {
            throw new \RuntimeException(
                sprintf('Can\'t move sitemaps to "%s" - directory is not writeable', $targetDir)
            );
        }

        $this->deleteExistingSitemaps($targetDir);

        // no need to delete the root file as it always exists, it will be overwritten
        $this->filesystem->mirror($this->tmpFolder, $targetDir, null, ['override' => true]);
    }

    /**
     * Deletes sitemap files matching filename patterns of newly generated files
     *
     * @param string $targetDir
     */
    protected function deleteExistingSitemaps(string $targetDir): void
    {
        foreach ($this->urlsets as $urlset) {
            if (preg_match('/.*_\d+\.xml(\.gz)?$/', $urlset->getLoc())) {
                continue; // skip numbered files
            }

            // pattern is base name of sitemap file (with .xml cut) optionally followed by _X for numbered files
            $basename = basename($urlset->getLoc());
            /** @var string $basename */
            $basename = preg_replace('/\.xml(\.gz)?$/', '', $basename); // cut .xml|.xml.gz
            $pattern = '/' . preg_quote($basename, '/') . '(_\d+)?\.xml(\.gz)?$/';

            foreach (Finder::create()->in($targetDir)->depth(0)->name($pattern)->files() as $file) {
                // old sitemap files are removed only if not existing in new file set
                if (!$this->filesystem->exists($this->tmpFolder . '/' . $file->getFilename())) {
                    $this->filesystem->remove($file);
                }
            }
        }
    }

    /**
     * Create new DumpingUrlset with gz option
     *
     * @param string                  $name        The urlset name
     * @param \DateTimeInterface|null $lastmod     The urlset last modification date
     * @param bool                    $gzExtension Whether the urlset is gzipped
     *
     * @return DumpingUrlset|Urlset
     */
    protected function newUrlset(string $name, \DateTimeInterface $lastmod = null, bool $gzExtension = false): Urlset
    {
        $url = $this->baseUrl . $this->sitemapFilePrefix . '.' . $name . '.xml';
        if ($gzExtension) {
            $url .= '.gz';
        }

        return new DumpingUrlset($url, $lastmod);
    }
}


text:
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
import KeyboardAccelerators from '../utils/KeyboardAccelerators';
import DOMUtils from '../utils/DOM';
import Drop from '../utils/Drop';
import Intl from '../utils/Intl';
import Props from '../utils/Props';
import Responsive from '../utils/Responsive';
import Box from './Box';
import Button from './Button';
import DropCaretIcon from './icons/base/Down';
import MoreIcon from './icons/base/More';
import CSSClassnames from '../utils/CSSClassnames';

const CLASS_ROOT = CSSClassnames.MENU;

function isFunction (obj) {
  return obj && obj.constructor && obj.call && obj.apply;
}

// We have a separate module for the drop component
// so we can transfer the router context.
class MenuDrop extends Component {

  constructor() {
    super();

    this._onUpKeyPress = this._onUpKeyPress.bind(this);
    this._onDownKeyPress = this._onDownKeyPress.bind(this);
    this._processTab = this._processTab.bind(this);
  }

  getChildContext () {
    return {
      intl: this.props.intl,
      history: this.props.history,
      router: this.props.router,
      store: this.props.store
    };
  }

  componentDidMount () {
    this._originalFocusedElement = document.activeElement;
    this._keyboardHandlers = {
      tab: this._processTab,
      up: this._onUpKeyPress,
      left: this._onUpKeyPress,
      down: this._onDownKeyPress,
      right: this._onDownKeyPress
    };
    KeyboardAccelerators.startListeningToKeyboard(this, this._keyboardHandlers);

    let container = ReactDOM.findDOMNode(this.refs.navContainer);
    let menuItems = container.childNodes;
    for (let i = 0; i < menuItems.length; i++) {
      let classes = menuItems[i].className.toString();
      let tagName = menuItems[i].tagName.toLowerCase();
      // want to skip items of the menu that are not focusable.
      if (tagName !== 'button' && tagName !== 'a' &&
        classes.indexOf('check-box') === -1) {
        continue;
      }
      menuItems[i].setAttribute('role', 'menuitem');

      if (!menuItems[i].getAttribute('id')) {
        menuItems[i].setAttribute('id', `menu_item_${i}`);
      }
    }

    container.setAttribute('aria-activedescendant',
      menuItems[0].getAttribute('id'));

    const menuDrop = ReactDOM.findDOMNode(this.refs.menuDrop);
    var items = menuDrop.getElementsByTagName('*');
    var firstFocusable = DOMUtils.getBestFirstFocusable(items);
    if (firstFocusable) {
      firstFocusable.focus();
    }
  }

  componentWillUnmount () {
    if (this._originalFocusedElement.focus) {
      this._originalFocusedElement.focus();
    } else if (this._originalFocusedElement.parentNode &&
      this._originalFocusedElement.parentNode.focus) {
      // required for IE11 and Edge
      this._originalFocusedElement.parentNode.focus();
    }
    KeyboardAccelerators.stopListeningToKeyboard(this, this._keyboardHandlers);
  }

  _processTab (event) {
    let container = ReactDOM.findDOMNode(this.refs.menuDrop);
    var items = container.getElementsByTagName('*');
    items = DOMUtils.filterByFocusable(items);

    if (!items || items.length === 0) {
      event.preventDefault();
    } else {
      if (event.shiftKey) {
        if (event.target === items[0]) {
          items[items.length - 1].focus();
          event.preventDefault();
        }
      } else if (event.target === items[items.length - 1]) {
        items[0].focus();
        event.preventDefault();
      }
    }
  }

  _onUpKeyPress (event) {
    event.preventDefault();
    var container = ReactDOM.findDOMNode(this.refs.navContainer);
    let menuItems = container.childNodes;
    if (!this.activeMenuItem) {
      let lastMenuItem = menuItems[menuItems.length - 1];
      this.activeMenuItem = lastMenuItem;
    } else if (this.activeMenuItem.previousSibling) {
      this.activeMenuItem = this.activeMenuItem.previousSibling;
    }

    let classes = this.activeMenuItem.className.split(/\s+/);
    let tagName = this.activeMenuItem.tagName.toLowerCase();
    // want to skip items of the menu that are not focusable.
    if (tagName !== 'button' && tagName !== 'a' &&
      classes.indexOf('check-box') === -1) {
      if (this.activeMenuItem === menuItems[0]) {
        return true;
      } else {
        // If this item is not focusable, check the next item.
        return this._onUpKeyPress(event);
      }
    }

    this.activeMenuItem.focus();
    container.setAttribute('aria-activedescendant',
      this.activeMenuItem.getAttribute('id'));
    // Stops KeyboardAccelerators from calling the other listeners.
    // Works limilar to event.stopPropagation().
    return true;
  }

  _onDownKeyPress (event) {
    event.preventDefault();
    var container = ReactDOM.findDOMNode(this.refs.navContainer);
    let menuItems = container.childNodes;
    if (!this.activeMenuItem) {
      this.activeMenuItem = menuItems[0];
    } else if (this.activeMenuItem.nextSibling) {
      this.activeMenuItem = this.activeMenuItem.nextSibling;
    }

    let classes = this.activeMenuItem.className.split(/\s+/);
    let tagName = this.activeMenuItem.tagName.toLowerCase();
    // want to skip items of the menu that are not focusable.
    if (tagName !== 'button' && tagName !== 'a' &&
      classes.indexOf('check-box') === -1) {
      if (this.activeMenuItem === menuItems[menuItems.length - 1]) {
        return true;
      } else {
        // If this item is not focusable, check the next item.
        return this._onDownKeyPress(event);
      }
    }

    this.activeMenuItem.focus();
    container.setAttribute('aria-activedescendant',
      this.activeMenuItem.getAttribute('id'));
    // Stops KeyboardAccelerators from calling the other listeners.
    // Works limilar to event.stopPropagation().
    return true;
  }

  render () {
    let { dropAlign, size, control, id, colorIndex, onClick } = this.props;
    let boxProps = Props.pick(this.props, Object.keys(Box.propTypes));
    delete boxProps.colorIndex; // manage colorIndex at the outer menuDrop element

    delete boxProps.onClick;

    delete boxProps.size;

    // Put nested Menus inline
    const children = React.Children.map(this.props.children, child => {
      let result = child;
      if (child && isFunction(child.type) && child.type.prototype._renderMenuDrop) {
        result = React.cloneElement(child, {inline: 'explode', direction: 'column'});
      }
      return result;
    });

    let contents = [
      React.cloneElement(control, {key: 'control', fill: true}),
      <Box {...boxProps} key="nav" ref="navContainer"
        role="menu" tag="nav" className={`${CLASS_ROOT}__contents`}
        primary={false}>
        {children}
      </Box>
    ];

    if (dropAlign.bottom) {
      contents.reverse();
    }

    let classes = classnames(
      `${CLASS_ROOT}__drop`,
      {
        [`${CLASS_ROOT}__drop--align-right`]: dropAlign.right,
        [`${CLASS_ROOT}__drop--${size}`]: size
      }
    );

    return (
      <Box ref="menuDrop" id={id} className={classes} colorIndex={colorIndex}
        onClick={onClick}>
        {contents}
      </Box>
    );
  }
}

MenuDrop.propTypes = {
  ...Box.propTypes,
  control: PropTypes.node,
  dropAlign: Drop.alignPropType,
  id: PropTypes.string.isRequired,
  onClick: PropTypes.func.isRequired,
  router: PropTypes.any,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
  store: PropTypes.any
};

MenuDrop.childContextTypes = {
  intl: PropTypes.any,
  history: PropTypes.any,
  router: PropTypes.any,
  store: PropTypes.any
};

export default class Menu extends Component {

  constructor(props) {
    super(props);

    this._onOpen = this._onOpen.bind(this);
    this._onClose = this._onClose.bind(this);
    this._onSink = this._onSink.bind(this);
    this._onResponsive = this._onResponsive.bind(this);
    this._onFocusControl = this._onFocusControl.bind(this);
    this._onBlurControl = this._onBlurControl.bind(this);

    let inline;
    if (props.hasOwnProperty('inline')) {
      inline = props.inline;
    } else {
      inline = (! props.label && ! props.icon);
    }
    let responsive;
    if (props.hasOwnProperty('responsive')) {
      responsive = props.responsive;
    } else {
      responsive = (inline && 'row' === props.direction);
    }
    this.state = {
      // state may be 'collapsed', 'focused' or 'expanded' (active).
      state: 'collapsed',
      initialInline: inline,
      inline: inline,
      responsive: responsive,
      dropId: 'menuDrop'
    };
  }

  componentDidMount () {
    if (this.refs.control) {
      let controlElement = this.refs.control.firstChild;
      this.setState({
        dropId: 'menu-drop-' + DOMUtils.generateId(controlElement),
        controlHeight: controlElement.clientHeight
      });
    }

    if (this.state.responsive) {
      this._responsive = Responsive.start(this._onResponsive);
    }
  }

  componentDidUpdate (prevProps, prevState) {
    if (this.state.state !== prevState.state) {
      let activeKeyboardHandlers = {
        esc: this._onClose
      };
      let focusedKeyboardHandlers = {
        space: this._onOpen,
        down: this._onOpen,
        enter: this._onOpen
      };

      switch (this.state.state) {
        case 'collapsed':
          KeyboardAccelerators.stopListeningToKeyboard(
            this, focusedKeyboardHandlers
          );
          KeyboardAccelerators.stopListeningToKeyboard(
            this, activeKeyboardHandlers
          );
          document.removeEventListener('click', this._onClose);
          if (this._drop) {
            this._drop.remove();
            this._drop = null;
          }
          break;
        case 'focused':
          KeyboardAccelerators.stopListeningToKeyboard(
            this, activeKeyboardHandlers
          );
          KeyboardAccelerators.startListeningToKeyboard(
            this, focusedKeyboardHandlers
          );
          break;
        case 'expanded':
          KeyboardAccelerators.stopListeningToKeyboard(
            this, focusedKeyboardHandlers
          );
          KeyboardAccelerators.startListeningToKeyboard(
            this, activeKeyboardHandlers
          );
          document.addEventListener('click', this._onClose);
          this._drop = Drop.add(this.refs.control,
            this._renderMenuDrop(),
            {
              align: this.props.dropAlign,
              colorIndex: this.props.dropColorIndex
            });
          this._drop.render(this._renderMenuDrop());
          break;
      }
    } else if (this.state.state === 'expanded') {
      this._drop.render(this._renderMenuDrop());
    }
  }

  componentWillUnmount () {
    document.removeEventListener('click', this._onClose);
    KeyboardAccelerators.stopListeningToKeyboard(this);
    if (this._drop) {
      this._drop.remove();
    }
    if (this._responsive) {
      this._responsive.stop();
    }
  }

  _onOpen () {
    this.setState({state: 'expanded'});
  }

  _onClose () {
    this.setState({state: 'collapsed'});
  }

  _onSink (event) {
    event.stopPropagation();
    // need to go native to prevent closing via document
    event.nativeEvent.stopImmediatePropagation();
  }

  _onResponsive (small) {
    // deactivate if we change resolutions
    let newState = this.state.state;
    if (this.state.state === 'expanded') {
      newState = 'focused';
    }
    if (small) {
      this.setState({inline: false, active: newState, controlCollapsed: true});
    } else {
      this.setState({
        inline: this.state.initialInline,
        active: newState,
        state: 'collapsed',
        controlCollapsed: false
      });
    }
  }

  _onFocusControl () {
    this.setState({state: 'focused'});
  }

  _onBlurControl () {
    if (this.state.state === 'focused') {
      this.setState({state: 'collapsed'});
    }
  }

  _renderControlContents () {
    let icon, label;

    // If this is a collapsed inline Menu, use any icon and/or label provided,
    // revert to default icon if neither.
    if (this.props.icon) {
      icon = React.cloneElement(this.props.icon, {key: 'icon'});
    }
    if (this.props.label) {
      label = [
        <span key="label" className={`${CLASS_ROOT}__control-label`}>
          {this.props.label}
        ,
        <DropCaretIcon key="caret" a11yTitle='menu-down'
          a11yTitleId='menu-down-id' />
      ];
    }
    if (! icon && ! label) {
      icon = <MoreIcon key="icon" />;
    }
    return [icon, label];
  }

  _renderMenuDrop () {
    let closeLabel = Intl.getMessage(this.context.intl, 'Close');
    let menuLabel = Intl.getMessage(this.context.intl, 'Menu');
    let menuTitle = (
      `${closeLabel} ${this.props.a11yTitle || this.props.label || ''} ${menuLabel}`
    );

    let control = (
      <Button plain={true} className={`${CLASS_ROOT}__control`}
        a11yTitle={menuTitle}
        style={{lineHeight: this.state.controlHeight + 'px'}}
        onClick={this._onClose}>
        {this._renderControlContents()}
      </Button>
    );

    let boxProps = Props.pick(this.props, Object.keys(Box.propTypes));
    let onClick = this.props.closeOnClick ? this._onClose : this._onSink;

    return (
      <MenuDrop {...boxProps} {...this.context}
        dropAlign={this.props.dropAlign}
        size={this.props.size}
        onClick={onClick}
        id={this.state.dropId}
        control={control}>
        {this.props.children}
      </MenuDrop>
    );
  }

  render () {
    let classes = classnames(
      CLASS_ROOT,
      this.props.className,
      {
        [`${CLASS_ROOT}--${this.props.direction}`]: this.props.direction,
        [`${CLASS_ROOT}--${this.props.size}`]: this.props.size,
        [`${CLASS_ROOT}--primary`]: this.props.primary,
        [`${CLASS_ROOT}--inline`]: this.state.inline,
        [`${CLASS_ROOT}--explode`]: 'explode' === this.state.inline,
        [`${CLASS_ROOT}--controlled`]: !this.state.inline,
        [`${CLASS_ROOT}__control`]: !this.state.inline,
        [`${CLASS_ROOT}--labelled`]: !this.state.inline && this.props.label
      }
    );

    if (this.state.inline) {
      let boxProps = Props.pick(this.props, Object.keys(Box.propTypes));
      let label;
      if ('explode' === this.state.inline) {
        label = (
          <div className={`${CLASS_ROOT}__label`}>
            {this.props.label}

        );
      }

      return (
        <Box {...boxProps} tag="nav" id={this.props.id}
          className={classes} primary={false}>
          {label}
          {this.props.children}
        </Box>
      );

    } else {
      let controlContents = this._renderControlContents();
      let openLabel = Intl.getMessage(this.context.intl, 'Open');
      let menuLabel = Intl.getMessage(this.context.intl, 'Menu');
      let menuTitle = (
        `${openLabel} ${this.props.a11yTitle || this.props.label || ''} ${menuLabel}`
      );

      return (

          <Button plain={true} id={this.props.id}
            className={classes}
            tabIndex="0"
            style={{lineHeight: this.state.controlHeight + 'px'}}
            onClick={this._onOpen}
            a11yTitle={menuTitle}
            onFocus={this._onFocusControl}
            onBlur={this._onBlurControl}>
            {controlContents}
          </Button>

      );

    }
  }
}

Menu.propTypes = {
  closeOnClick: PropTypes.bool,
  dropAlign: Drop.alignPropType,
  dropColorIndex: PropTypes.string,
  icon: PropTypes.node,
  id: PropTypes.string,
  inline: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf('expand')]),
  label: PropTypes.string,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
  ...Box.propTypes
};

Menu.contextTypes = {
  intl: PropTypes.any,
  history: PropTypes.any,
  router: PropTypes.any,
  store: PropTypes.any
};

Menu.defaultProps = {
  closeOnClick: true,
  direction: 'column',
  dropAlign: {top: 'top', left: 'left'},
  pad: 'none'
};


text:
const url = "http://localhost:3001/api/forecast/";
let $notifier = $("#notifier");
let $forecastConteiner = $('#forecast-conteiner');

$("#btn-forecast").click(() => {
    let town = $('#input-town').val();
    $notifier.html('Getting your forecast!');
    $forecastConteiner.html("");

    if (town.length < 1) {
        $notifier.html("Please choice a town!");

        setTimeout(() => {
            $notifier.html("");
        }, 5000);

        return;
    }

    $.ajax({
        url: url + town
    }).then(res => {
        $notifier.html("");

        $forecastConteiner.append(`<h3>Town: ${res.location.name}</h3>`);
        $forecastConteiner.append(`<div>Country: ${res.location.country}</div>`);

        $forecastConteiner.append(`<div>Celsius: ${res.current.temp_c}</div>`);
        $forecastConteiner.append(`<div>Condition: ${res.current.condition.text}</div>`);

        $forecastConteiner.append(`<img src="${res.current.condition.icon.trimLeft('/')}" class="img-thumbnail"/>`);

        $forecastConteiner.append(`<div>Wind: ${res.current.wind_kph}</div>`);
    })
})


text:
This module was extracted from our internally used logistics system. Extraction WIP.
Tests not yet extracted. Avoid usage or use with caution.

## Installation

Add this line to your application's Gemfile:

    gem 'bliss_hash_items'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install bliss_hash_items

## Usage

```ruby
class YourReceiptClass < ActiveRecord::Base
  include BlissHashItems

  has_many :line_items
  # ...
end

receipt = YourReceiptClass.new
receipt.respond_to? :line_items_to_hash # => true
```


text:
#ifndef VICE_OUTPUT_H
#define VICE_OUTPUT_H

#define OUTPUT_PIXEL_BLACK '*'
#define OUTPUT_PIXEL_WHITE ' '
#define OUTPUT_NEWLINE '\n'

struct palette_s;

struct output_parameter_s
{
    unsigned int maxcol;
    unsigned int maxrow;
    unsigned int dpi_x;
    unsigned int dpi_y;
    struct palette_s *palette;
};
typedef struct output_parameter_s output_parameter_t;

#endif


text:
<?php

namespace FluentPDO;

use PDO;

class FluentPDO {

	public $pdo;

	protected $structure;

	/** @var boolean|callback */
	public $debug;

	function __construct( PDO $pdo, Fluent\Structure $structure = null) {
		$this->pdo = $pdo;
		if (!$structure) {
			$structure = new Fluent\Structure;
		}
		$this->structure = $structure;
	}

	/** Create SELECT query from $table
	 * @param string $table  db table name
	 * @param integer $primaryKey  return one row by primary key
	 * @return FluentPDO\Query\Select
	 */
	public function from($table, $primaryKey = null) {

		$query = new Query\Select($this, $table);
		if ($primaryKey) {
			$tableTable = $query->getFromTable();
			$tableAlias = $query->getFromAlias();
			$primaryKeyName = $this->structure->getPrimaryKey($tableTable);
			$query = $query->where("$tableAlias.$primaryKeyName", $primaryKey);
		}
		return $query;
	}

	/** Create INSERT INTO query
	 *
	 * @param string $table
	 * @param array $values  you can add one or multi rows array @see docs
	 * @return FluentPDO\Query\Insert
	 */
	public function insertInto($table, $values = array()) {

		$query = new Query\Insert($this, $table, $values);
		return $query;
	}

	/** Create UPDATE query
	 *
	 * @param string $table
	 * @param array|string $set
	 * @param string $primaryKey
	 *
	 * @return FluentPDO\Query\Update
	 */
	public function update($table, $set = array(), $primaryKey = null) {

		$query = new Query\Update($this, $table);
		$query->set($set);
		if ($primaryKey) {
			$primaryKeyName = $this->getStructure()->getPrimaryKey($table);
			$query = $query->where($primaryKeyName, $primaryKey);
		}
		return $query;
	}

	/** Create DELETE query
	 *
	 * @param string $table
	 * @param string $primaryKey  delete only row by primary key
	 * @return FluentPDO\Query\Delete
	 */
	public function delete($table, $primaryKey = null) {

		$query = new Query\Delete($this, $table);
		if ($primaryKey) {
			$primaryKeyName = $this->getStructure()->getPrimaryKey($table);
			$query = $query->where($primaryKeyName, $primaryKey);
		}
		return $query;
	}

	/** Create DELETE FROM query
	 *
	 * @param string $table
	 * @param string $primaryKey
	 * @return FluentPDO\Query\Delete
	 */
	public function deleteFrom($table, $primaryKey = null) {
		$args = func_get_args();
		return call_user_func_array(array($this, 'delete'), $args);
	}

	/** @return \PDO
	 */
	public function getPdo() {
		return $this->pdo;
	}

	/** @return \FluentStructure
	 */
	public function getStructure() {
		return $this->structure;
	}
}


text:
.class Landroid/support/v4/view/GravityCompat$GravityCompatImplJellybeanMr1;
.super Ljava/lang/Object;
.source "GravityCompat.java"

# interfaces
.implements Landroid/support/v4/view/GravityCompat$GravityCompatImpl;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/support/v4/view/GravityCompat;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = "GravityCompatImplJellybeanMr1"
.end annotation

# direct methods
.method constructor <init>()V
    .locals 0

    .prologue
    .line 62
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

# virtual methods
.method public apply(IIILandroid/graphics/Rect;IILandroid/graphics/Rect;I)V
    .locals 0
    .parameter "gravity"
    .parameter "w"
    .parameter "h"
    .parameter "container"
    .parameter "xAdj"
    .parameter "yAdj"
    .parameter "outRect"
    .parameter "layoutDirection"

    .prologue
    .line 77
    invoke-static/range {p1 .. p8}, Landroid/support/v4/view/GravityCompatJellybeanMr1;->apply(IIILandroid/graphics/Rect;IILandroid/graphics/Rect;I)V

    .line 79
    return-void
.end method

.method public apply(IIILandroid/graphics/Rect;Landroid/graphics/Rect;I)V
    .locals 0
    .parameter "gravity"
    .parameter "w"
    .parameter "h"
    .parameter "container"
    .parameter "outRect"
    .parameter "layoutDirection"

    .prologue
    .line 71
    invoke-static/range {p1 .. p6}, Landroid/support/v4/view/GravityCompatJellybeanMr1;->apply(IIILandroid/graphics/Rect;Landroid/graphics/Rect;I)V

    .line 72
    return-void
.end method

.method public applyDisplay(ILandroid/graphics/Rect;Landroid/graphics/Rect;I)V
    .locals 0
    .parameter "gravity"
    .parameter "display"
    .parameter "inoutObj"
    .parameter "layoutDirection"

    .prologue
    .line 83
    invoke-static {p1, p2, p3, p4}, Landroid/support/v4/view/GravityCompatJellybeanMr1;->applyDisplay(ILandroid/graphics/Rect;Landroid/graphics/Rect;I)V

    .line 84
    return-void
.end method

.method public getAbsoluteGravity(II)I
    .locals 1
    .parameter "gravity"
    .parameter "layoutDirection"

    .prologue
    .line 65
    invoke-static {p1, p2}, Landroid/support/v4/view/GravityCompatJellybeanMr1;->getAbsoluteGravity(II)I

    move-result v0

    return v0
.end method


text:
<?xml version='1.0' encoding='UTF-8'?>
<Info location="nsoltAtomExtension2dLayer.m" type="File" />


text:
echo "$LINK" >link.cmd
exit_value=0

#
# If link.sed already exists, use it.  We assume a previous run of link.sh has
# found the correct set of libraries.
#
if test -f link.sed; then
  echo "link.sh: The file 'link.sed' exists, which is going to be used now."
  echo "link.sh: If linking fails, try deleting the link.sed file."
  echo "link.sh: If this fails too, try creating an empty link.sed file."
else

#
# If linking works with the full link command, try removing some libraries,
# that are know not to be needed on at least one system.
# Remove pathdef.c if there is a new link command and compile it again.
#
# Note: Can't remove Xext; It links fine but will give an error when running
# gvim with Motif.
#
  cat link.cmd
  if sh link.cmd; then
    touch link.sed
    for libname in SM ICE nsl dnet dnet_stub inet socket dir elf Xmu Xpm x pthread thread readline; do
      if grep "l$libname " link.cmd >/dev/null; then
        if test ! -f link1.sed; then
          echo "link.sh: OK, linking works, let's try removing a few libraries..."
        fi
        echo "link.sh: Trying to remove the $libname library..."
        echo "s/-l$libname  *//g" >link1.sed
        sed -f link.sed <link.cmd >linkit2.sh
        sed -f link1.sed <linkit2.sh >linkit.sh
        cat linkit.sh
        if sh linkit.sh; then
          echo "link.sh: We don't need the $libname library!"
          cat link1.sed >>link.sed
          rm -f pathdef.c
        else
          echo "link.sh: We DO need the $libname library."
        fi
      fi
    done
    if test ! -f pathdef.c; then
      $MAKE pathdef.o
    fi
    if test ! -f link1.sed; then
      echo "link.sh: Linked fine, no libraries can be removed"
      touch link3.sed
    fi
  else
    exit_value=$?
  fi
fi

#
# Now do the real linking.
#
if test -s link.sed; then
  echo "link.sh: Using link.sed file to remove a few libraries"
  sed -f link.sed <link.cmd >linkit.sh
  cat linkit.sh
  if sh linkit.sh; then
    exit_value=0
    echo "link.sh: Linked fine with a few libraries removed"
  else
    exit_value=$?
    echo "link.sh: Linking failed, making link.sed empty and trying again"
    mv -f link.sed link2.sed
    touch link.sed
    rm -f pathdef.c
    $MAKE pathdef.o
  fi
fi
if test -f link.sed -a ! -s link.sed -a ! -f link3.sed; then
  echo "link.sh: Using unmodified link command"
  cat link.cmd
  if sh link.cmd; then
    exit_value=0
    echo "link.sh: Linked OK"
  else
    exit_value=$?
    if test -f link2.sed; then
      echo "link.sh: Linking doesn't work at all, removing link.sed"
      rm -f link.sed
    fi
  fi
fi

#
# cleanup
#
rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh

#
# return an error code if something went wrong
#
exit $exit_value

# vim:set sw=2 et:


text:
//wxConvertApp Programming Utility
/*This program currently offers 3 useful conversions
1.  Converts most of an .RC file into a wxXml file
2.  Converts most of an .wxr file into a wxXml file
3.  Converts portions of an .RC file into a wxr file
*/

#ifdef __GNUG__
#pragma implementation "convert.h"
#endif

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/image.h"

#include "wx/deprecated/setup.h"
#include "wx/deprecated/resource.h"

#include "convert.h"
#include "rc2wxr.h"
#include "wxr2xml.h"
#include "rc2xml.h"

IMPLEMENT_APP(wxConvertApp)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

wxConvertApp::wxConvertApp()
{
    m_pFrame=NULL;
    m_pMenuBar=NULL;

}

wxConvertApp::~wxConvertApp()
{

}

bool wxConvertApp::OnInit()
{
//Initialize all image loaders(JPEG,BMP,PNG,and etc)
    wxInitAllImageHandlers();
    SetAppName(_T("wxConvertApp"));

    if (HandleCommandLine())
        return true;

// Create the main frame window
    m_pFrame = new wxMainFrame(NULL, wxID_ANY, _T("wxConvertApp"), wxPoint(0, 0), wxSize(500, 400),
        wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);

    InitMenu();
    m_pFrame->Show(true);
    SetTopWindow(m_pFrame);
    return true;
}

void wxConvertApp::InitMenu()
{
    m_pMenuBar=new wxMenuBar;
    wxASSERT(m_pMenuBar);

    wxMenu *filemenu=new wxMenu;
    filemenu->Append(ID_RC2WXR,_T("Convert RC file to WXR file"));
    filemenu->Append(ID_WXR2XML,_T("Convert WXR file to XML file"));
    filemenu->Append(ID_RC2XML,_T("Convert RC file to XML file"));

    filemenu->Append(ID_QUIT, _T("E&xit"));
    m_pMenuBar->Append(filemenu,_T("&File"));

    m_pFrame->SetMenuBar(m_pMenuBar);
}

// MainFrame.cpp: implementation of the wxMainFrame class.
//
//////////////////////////////////////////////////////////////////////

BEGIN_EVENT_TABLE(wxMainFrame, wxFrame)
    EVT_MENU(ID_QUIT,wxMainFrame::OnQuit)
    EVT_MENU(ID_RC2WXR,wxMainFrame::OnRc2Wxr)
    EVT_MENU(ID_WXR2XML,wxMainFrame::OnWXR2XML)
    EVT_MENU(ID_RC2XML,wxMainFrame::OnRC2XML)
END_EVENT_TABLE()

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

wxMainFrame::wxMainFrame(wxWindow* parent,wxWindowID id,
const wxString& title, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
:wxFrame(parent,id,title,pos,size,style,name)
{

}

wxMainFrame::~wxMainFrame()
{
}

void wxMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(true);
}

void wxMainFrame::OnRc2Wxr(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_FILEDLG
    wxFileDialog filed(this);
    filed.SetWildcard(_T("*.rc"));
    filed.SetStyle(wxOPEN);

    if (filed.ShowModal()!=wxID_OK)
        return;

    wxFileDialog wxrfile(this,_T("Enter Desired WXR file name"));
    wxrfile.SetWildcard(_T("*.wxr"));
    wxrfile.SetStyle(wxOPEN);
    wxrfile.SetFilename(_T("resource.wxr"));

    if (wxrfile.ShowModal()!=wxID_OK)
        return;

    rc2wxr convert;
    convert.Convert(wxrfile.GetPath(),filed.GetPath());
#endif // wxUSE_FILEDLG
}

void wxMainFrame::OnWXR2XML(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_FILEDLG
    wxFileDialog f(this);
    f.SetWildcard(_T("*.wxr"));
    if (f.ShowModal()!=wxID_OK)
        return;

    wxFileDialog xmlfile(this,_T("Enter Desired XML file name"));
    xmlfile.SetWildcard(_T("*.xml"));
    xmlfile.SetStyle(wxOPEN);
    xmlfile.SetFilename(_T("resource.xml"));

    if (xmlfile.ShowModal()!=wxID_OK)
        return;

    wxr2xml XMLCon;
    XMLCon.Convert(f.GetPath(),xmlfile.GetPath());
#endif // wxUSE_FILEDLG
}

void wxMainFrame::OnRC2XML(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_FILEDLG
    wxFileDialog f(this);
    f.SetWildcard(_T("*.rc"));
    if (f.ShowModal()!=wxID_OK)
        return;

    wxFileDialog xmlfile(this,_T("Enter Desired XML file name"));
    xmlfile.SetWildcard(_T("*.xml"));
    xmlfile.SetStyle(wxOPEN);
    xmlfile.SetFilename(_T("resource.xml"));

    if (xmlfile.ShowModal()!=wxID_OK)
        return;

    rc2xml XMLCon;
    XMLCon.Convert(f.GetPath(),xmlfile.GetPath());
#endif // wxUSE_FILEDLG
}

bool wxConvertApp::HandleCommandLine()
{

   if (argc != 2)
       return false;

//Figure out kind of conversion
    wxString source,target;

    wxr2xml trans_wxr2xml;
    rc2xml trans_rc2xml;
    rc2wxr trans_rc2wxr;

    source=argv[1];
    target=argv[2];

    if ((source.Find(_T(".wxr"))>0)&&(target.Find(_T(".xml"))>0))
        {
        trans_wxr2xml.Convert(source,target);
        return true;
        }
    else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".wxr"))!=wxNOT_FOUND))
        {
        trans_rc2wxr.Convert(source,target);
        return true;
        }
    else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".xml"))!=wxNOT_FOUND))
        {
        trans_rc2xml.Convert(source,target);
        return true;
        }

    return false;
}


text:
title: Generate Barcode with Empty Bars in PHP
type: docs
weight: 30
url: /java/generate-barcode-with-empty-bars-in-php/
---

## **Aspose.BarCode - Generate Barcode with Empty Bars**
To Generate Barcode with Empty Bars using **Aspose.Barcode Java for PHP**, simply invoke **GenerateBarcodeWithEmptyBars** module. Here you can see example code.

**PHPCode**

{{< highlight php >}}

 # Instantiate barcode object

$symbology = new Symbology();

$bb = new BarCodeBuilder("TEXT", $symbology->Code128);

\# Set the FilledBars property to false

$bb->setFilledBars(false);

$bb->save($dataDir . "GenerateBarcodeWithEmptyBars.jpg");

\# Display Status.

print "Generate Barcode With Empty Bars, please check the output file.".PHP_EOL;

{{< /highlight >}}
## **Download Running Code**
Download **Generate Barcode with Empty Bars (Aspose.BarCode)** from any of the below mentioned social coding sites:

- [GitHub](https://github.com/aspose-barcode/Aspose.BarCode-for-Java/blob/master/Plugins/Aspose_Barcode_Java_for_PHP/src/aspose/barcode/WorkingWithBarcodeImage/BarcodeImageBasicFeatures/GenerateBarcodeWithEmptyBars.php)
- [CodePlex](https://asposebarcodejavaphp.codeplex.com/SourceControl/latest#src/aspose/barcode/WorkingWithBarcodeImage/BarcodeImageBasicFeatures/GenerateBarcodeWithEmptyBars.php)


text:
<?php

/**
 * @see Zend_Db_Adapter_Abstract
 */
#require_once 'Zend/Db/Adapter/Abstract.php';

/**
 * @see Zend_Db_Statement_Oracle
 */
#require_once 'Zend/Db/Statement/Oracle.php';

/**
 * @category   Zend
 * @package    Zend_Db
 * @subpackage Adapter
 * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
{
    /**
     * User-provided configuration.
     *
     * Basic keys are:
     *
     * username => (string) Connect to the database as this username.
     * password => (string) Password associated with the username.
     * dbname   => Either the name of the local Oracle instance, or the
     *             name of the entry in tnsnames.ora to which you want to connect.
     * persistent => (boolean) Set TRUE to use a persistent connection
     * @var array
     */
    protected $_config = array(
        'dbname'       => null,
        'username'     => null,
        'password'     => null,
        'persistent'   => false
    );

    /**
     * Keys are UPPERCASE SQL datatypes or the constants
     * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
     *
     * Values are:
     * 0 = 32-bit integer
     * 1 = 64-bit integer
     * 2 = float or decimal
     *
     * @var array Associative array of datatypes to values 0, 1, or 2.
     */
    protected $_numericDataTypes = array(
        Zend_Db::INT_TYPE    => Zend_Db::INT_TYPE,
        Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
        Zend_Db::FLOAT_TYPE  => Zend_Db::FLOAT_TYPE,
        'BINARY_DOUBLE'      => Zend_Db::FLOAT_TYPE,
        'BINARY_FLOAT'       => Zend_Db::FLOAT_TYPE,
        'NUMBER'             => Zend_Db::FLOAT_TYPE,
    );

    /**
     * @var integer
     */
    protected $_execute_mode = null;

    /**
     * Default class name for a DB statement.
     *
     * @var string
     */
    protected $_defaultStmtClass = 'Zend_Db_Statement_Oracle';

    /**
     * Check if LOB field are returned as string
     * instead of OCI-Lob object
     *
     * @var boolean
     */
    protected $_lobAsString = null;

    /**
     * Creates a connection resource.
     *
     * @return void
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    protected function _connect()
    {
        if (is_resource($this->_connection)) {
            // connection already exists
            return;
        }

        if (!extension_loaded('oci8')) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but the extension is not loaded');
        }

        $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);

        $connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect';

        $this->_connection = @$connectionFuncName(
                $this->_config['username'],
                $this->_config['password'],
                $this->_config['dbname'],
                $this->_config['charset']);

        // check the connection
        if (!$this->_connection) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception(oci_error());
        }
    }

    /**
     * Test if a connection is active
     *
     * @return boolean
     */
    public function isConnected()
    {
        return ((bool) (is_resource($this->_connection)
                    && (get_resource_type($this->_connection) == 'oci8 connection'
                     || get_resource_type($this->_connection) == 'oci8 persistent connection')));
        }

    /**
     * Force the connection to close.
     *
     * @return void
     */
    public function closeConnection()
    {
        if ($this->isConnected()) {
            oci_close($this->_connection);
        }
        $this->_connection = null;
    }

    /**
     * Activate/deactivate return of LOB as string
     *
     * @param string $lob_as_string
     * @return Zend_Db_Adapter_Oracle
     */
    public function setLobAsString($lobAsString)
    {
        $this->_lobAsString = (bool) $lobAsString;
        return $this;
    }

    /**
     * Return whether or not LOB are returned as string
     *
     * @return boolean
     */
    public function getLobAsString()
    {
        if ($this->_lobAsString === null) {
            // if never set by user, we use driver option if it exists otherwise false
            if (isset($this->_config['driver_options']) &&
                isset($this->_config['driver_options']['lob_as_string'])) {
                $this->_lobAsString = (bool) $this->_config['driver_options']['lob_as_string'];
            } else {
                $this->_lobAsString = false;
            }
        }
        return $this->_lobAsString;
    }

    /**
     * Returns an SQL statement for preparation.
     *
     * @param string $sql The SQL statement with placeholders.
     * @return Zend_Db_Statement_Oracle
     */
    public function prepare($sql)
    {
        $this->_connect();
        $stmtClass = $this->_defaultStmtClass;
        if (!class_exists($stmtClass)) {
            #require_once 'Zend/Loader.php';
            Zend_Loader::loadClass($stmtClass);
        }
        $stmt = new $stmtClass($this, $sql);
        if ($stmt instanceof Zend_Db_Statement_Oracle) {
            $stmt->setLobAsString($this->getLobAsString());
        }
        $stmt->setFetchMode($this->_fetchMode);
        return $stmt;
    }

    /**
     * Quote a raw string.
     *
     * @param string $value     Raw string
     * @return string           Quoted string
     */
    protected function _quote($value)
    {
        if (is_int($value) || is_float($value)) {
            return $value;
        }
        $value = str_replace("'", "''", $value);
        return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
    }

    /**
     * Quote a table identifier and alias.
     *
     * @param string|array|Zend_Db_Expr $ident The identifier or expression.
     * @param string $alias An alias for the table.
     * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
     * @return string The quoted identifier and alias.
     */
    public function quoteTableAs($ident, $alias = null, $auto = false)
    {
        // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
        return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
    }

    /**
     * Return the most recent value from the specified sequence in the database.
     * This is supported only on RDBMS brands that support sequences
     * (e.g. Oracle, PostgreSQL, DB2).  Other RDBMS brands return null.
     *
     * @param string $sequenceName
     * @return string
     */
    public function lastSequenceId($sequenceName)
    {
        $this->_connect();
        $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual';
        $value = $this->fetchOne($sql);
        return $value;
    }

    /**
     * Generate a new value from the specified sequence in the database, and return it.
     * This is supported only on RDBMS brands that support sequences
     * (e.g. Oracle, PostgreSQL, DB2).  Other RDBMS brands return null.
     *
     * @param string $sequenceName
     * @return string
     */
    public function nextSequenceId($sequenceName)
    {
        $this->_connect();
        $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual';
        $value = $this->fetchOne($sql);
        return $value;
    }

    /**
     * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
     *
     * As a convention, on RDBMS brands that support sequences
     * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
     * from the arguments and returns the last id generated by that sequence.
     * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
     * returns the last value generated for such a column, and the table name
     * argument is disregarded.
     *
     * Oracle does not support IDENTITY columns, so if the sequence is not
     * specified, this method returns null.
     *
     * @param string $tableName   OPTIONAL Name of table.
     * @param string $primaryKey  OPTIONAL Name of primary key column.
     * @return string
     */
    public function lastInsertId($tableName = null, $primaryKey = null)
    {
        if ($tableName !== null) {
            $sequenceName = $tableName;
            if ($primaryKey) {
                $sequenceName .= "_$primaryKey";
            }
            $sequenceName .= '_seq';
            return $this->lastSequenceId($sequenceName);
        }

        // No support for IDENTITY columns; return null
        return null;
    }

    /**
     * Returns a list of the tables in the database.
     *
     * @return array
     */
    public function listTables()
    {
        $this->_connect();
        $data = $this->fetchCol('SELECT table_name FROM all_tables');
        return $data;
    }

    /**
     * Returns the column descriptions for a table.
     *
     * The return value is an associative array keyed by the column name,
     * as returned by the RDBMS.
     *
     * The value of each array element is an associative array
     * with the following keys:
     *
     * SCHEMA_NAME      => string; name of schema
     * TABLE_NAME       => string;
     * COLUMN_NAME      => string; column name
     * COLUMN_POSITION  => number; ordinal position of column in table
     * DATA_TYPE        => string; SQL datatype name of column
     * DEFAULT          => string; default expression of column, null if none
     * NULLABLE         => boolean; true if column can have nulls
     * LENGTH           => number; length of CHAR/VARCHAR
     * SCALE            => number; scale of NUMERIC/DECIMAL
     * PRECISION        => number; precision of NUMERIC/DECIMAL
     * UNSIGNED         => boolean; unsigned property of an integer type
     * PRIMARY          => boolean; true if column is part of the primary key
     * PRIMARY_POSITION => integer; position of column in primary key
     * IDENTITY         => integer; true if column is auto-generated with unique values
     *
     * @todo Discover integer unsigned property.
     *
     * @param string $tableName
     * @param string $schemaName OPTIONAL
     * @return array
     */
    public function describeTable($tableName, $schemaName = null)
    {
        $version = $this->getServerVersion();
        if (($version === null) || version_compare($version, '9.0.0', '>=')) {
            $sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
                    TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
                    TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
                FROM ALL_TAB_COLUMNS TC
                LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
                    ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
                  ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
                WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
            $bind[':TBNAME'] = $tableName;
            if ($schemaName) {
                $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
                $bind[':SCNAME'] = $schemaName;
            }
            $sql .= ' ORDER BY TC.COLUMN_ID';
        } else {
            $subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
                from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
                  WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
                    AND ACC.TABLE_NAME = AC.TABLE_NAME
                    AND ACC.OWNER = AC.OWNER
                    AND AC.CONSTRAINT_TYPE = 'P'
                    AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
            $bind[':TBNAME'] = $tableName;
            if ($schemaName) {
                $subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
                $bind[':SCNAME'] = $schemaName;
            }
            $sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
                    TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
                    TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
                FROM ALL_TAB_COLUMNS TC, ($subSql) CC
                WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
                  AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
            if ($schemaName) {
                $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
            }
            $sql .= ' ORDER BY TC.COLUMN_ID';
        }

        $stmt = $this->query($sql, $bind);

        /**
         * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
         */
        $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);

        $table_name      = 0;
        $owner           = 1;
        $column_name     = 2;
        $data_type       = 3;
        $data_default    = 4;
        $nullable        = 5;
        $column_id       = 6;
        $data_length     = 7;
        $data_scale      = 8;
        $data_precision  = 9;
        $constraint_type = 10;
        $position        = 11;

        $desc = array();
        foreach ($result as $key => $row) {
            list ($primary, $primaryPosition, $identity) = array(false, null, false);
            if ($row[$constraint_type] == 'P') {
                $primary = true;
                $primaryPosition = $row[$position];
                /**
                 * Oracle does not support auto-increment keys.
                 */
                $identity = false;
            }
            $desc[$this->foldCase($row[$column_name])] = array(
                'SCHEMA_NAME'      => $this->foldCase($row[$owner]),
                'TABLE_NAME'       => $this->foldCase($row[$table_name]),
                'COLUMN_NAME'      => $this->foldCase($row[$column_name]),
                'COLUMN_POSITION'  => $row[$column_id],
                'DATA_TYPE'        => $row[$data_type],
                'DEFAULT'          => $row[$data_default],
                'NULLABLE'         => (bool) ($row[$nullable] == 'Y'),
                'LENGTH'           => $row[$data_length],
                'SCALE'            => $row[$data_scale],
                'PRECISION'        => $row[$data_precision],
                'UNSIGNED'         => null, // @todo
                'PRIMARY'          => $primary,
                'PRIMARY_POSITION' => $primaryPosition,
                'IDENTITY'         => $identity
            );
        }
        return $desc;
    }

    /**
     * Leave autocommit mode and begin a transaction.
     *
     * @return void
     */
    protected function _beginTransaction()
    {
        $this->_setExecuteMode(OCI_DEFAULT);
    }

    /**
     * Commit a transaction and return to autocommit mode.
     *
     * @return void
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    protected function _commit()
    {
        if (!oci_commit($this->_connection)) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
        }
        $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
    }

    /**
     * Roll back a transaction and return to autocommit mode.
     *
     * @return void
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    protected function _rollBack()
    {
        if (!oci_rollback($this->_connection)) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
        }
        $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
    }

    /**
     * Set the fetch mode.
     *
     * @todo Support FETCH_CLASS and FETCH_INTO.
     *
     * @param integer $mode A fetch mode.
     * @return void
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    public function setFetchMode($mode)
    {
        switch ($mode) {
            case Zend_Db::FETCH_NUM:   // seq array
            case Zend_Db::FETCH_ASSOC: // assoc array
            case Zend_Db::FETCH_BOTH:  // seq+assoc array
            case Zend_Db::FETCH_OBJ:   // object
                $this->_fetchMode = $mode;
                break;
            case Zend_Db::FETCH_BOUND: // bound to PHP variable
                /**
                 * @see Zend_Db_Adapter_Oracle_Exception
                 */
                #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
                throw new Zend_Db_Adapter_Oracle_Exception('FETCH_BOUND is not supported yet');
                break;
            default:
                /**
                 * @see Zend_Db_Adapter_Oracle_Exception
                 */
                #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
                throw new Zend_Db_Adapter_Oracle_Exception("Invalid fetch mode '$mode' specified");
                break;
        }
    }

    /**
     * Adds an adapter-specific LIMIT clause to the SELECT statement.
     *
     * @param string $sql
     * @param integer $count
     * @param integer $offset OPTIONAL
     * @return string
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    public function limit($sql, $count, $offset = 0)
    {
        $count = intval($count);
        if ($count <= 0) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument count=$count is not valid");
        }

        $offset = intval($offset);
        if ($offset < 0) {
            /**
             * @see Zend_Db_Adapter_Oracle_Exception
             */
            #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
            throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument offset=$offset is not valid");
        }

        /**
         * Oracle does not implement the LIMIT clause as some RDBMS do.
         * We have to simulate it with subqueries and ROWNUM.
         * Unfortunately because we use the column wildcard "*",
         * this puts an extra column into the query result set.
         */
        $limit_sql = "SELECT z2.*
            FROM (
                SELECT z1.*, ROWNUM AS \"zend_db_rownum\"
                FROM (
                    " . $sql . "
                ) z1
            ) z2
            WHERE z2.\"zend_db_rownum\" BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
        return $limit_sql;
    }

    /**
     * @param integer $mode
     * @throws Zend_Db_Adapter_Oracle_Exception
     */
    private function _setExecuteMode($mode)
    {
        switch($mode) {
            case OCI_COMMIT_ON_SUCCESS:
            case OCI_DEFAULT:
            case OCI_DESCRIBE_ONLY:
                $this->_execute_mode = $mode;
                break;
            default:
                /**
                 * @see Zend_Db_Adapter_Oracle_Exception
                 */
                #require_once 'Zend/Db/Adapter/Oracle/Exception.php';
                throw new Zend_Db_Adapter_Oracle_Exception("Invalid execution mode '$mode' specified");
                break;
        }
    }

    /**
     * @return int
     */
    public function _getExecuteMode()
    {
        return $this->_execute_mode;
    }

    /**
     * Check if the adapter supports real SQL parameters.
     *
     * @param string $type 'positional' or 'named'
     * @return bool
     */
    public function supportsParameters($type)
    {
        switch ($type) {
            case 'named':
                return true;
            case 'positional':
            default:
                return false;
        }
    }

    /**
     * Retrieve server version in PHP style
     *
     * @return string
     */
    public function getServerVersion()
    {
        $this->_connect();
        $version = oci_server_version($this->_connection);
        if ($version !== false) {
            $matches = null;
            if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
                return $matches[1];
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}


text:
package ma.glasnost.orika.impl.generator;

import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.MappingException;
import ma.glasnost.orika.constructor.ConstructorResolverStrategy;
import ma.glasnost.orika.constructor.ConstructorResolverStrategy.ConstructorMapping;
import ma.glasnost.orika.impl.GeneratedObjectFactory;
import ma.glasnost.orika.metadata.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.List;

import static java.lang.String.format;
import static ma.glasnost.orika.impl.generator.SourceCodeContext.append;
import static ma.glasnost.orika.impl.generator.SourceCodeContext.statement;

/**
 * ObjectFactoryGenerator generates source code which implements an
 * ObjectFactory capable of instantiating a given target type.
 */
public class ObjectFactoryGenerator {

    private final static Logger LOGGER = LoggerFactory.getLogger(ObjectFactoryGenerator.class);

    private final ConstructorResolverStrategy constructorResolverStrategy;
    private final MapperFactory mapperFactory;
    private final String nameSuffix;

    /**
     * Creates a new ObjectFactoryGenerator instance
     *
     * @param mapperFactory
     * @param constructorResolverStrategy
     * @param compilerStrategy
     */
    public ObjectFactoryGenerator(MapperFactory mapperFactory, ConstructorResolverStrategy constructorResolverStrategy,
            CompilerStrategy compilerStrategy) {
        this.mapperFactory = mapperFactory;
        this.nameSuffix = String.valueOf(System.nanoTime());
        this.constructorResolverStrategy = constructorResolverStrategy;
    }

    /**
     * @param type
     * @param sourceType
     * @param context
     * @return an instance of the newly generated ObjectFactory
     */
    public GeneratedObjectFactory build(Type<?> type, Type<?> sourceType, MappingContext context) {

        String className = type.getSimpleName() + "_" + sourceType.getSimpleName() + "_ObjectFactory" + nameSuffix;
        className = prependPackageName(getPackageName(type), className);
        try {
            StringBuilder logDetails;
            if (LOGGER.isDebugEnabled()) {
                logDetails = new StringBuilder();
                logDetails.append("Generating new object factory for (" + type + ")");
            } else {
                logDetails = null;
            }

            final SourceCodeContext factoryCode = new SourceCodeContext(className, GeneratedObjectFactory.class, context, logDetails);

            UsedTypesContext usedTypes = new UsedTypesContext();
            UsedConvertersContext usedConverters = new UsedConvertersContext();
            UsedMapperFacadesContext usedMapperFacades = new UsedMapperFacadesContext();

            addCreateMethod(factoryCode, usedTypes, usedConverters, usedMapperFacades, type, sourceType, context, logDetails);

            GeneratedObjectFactory objectFactory = (GeneratedObjectFactory) factoryCode.getInstance();
            objectFactory.setMapperFacade(mapperFactory.getMapperFacade());

            if (logDetails != null) {
                LOGGER.debug(logDetails.toString());
            }

            return objectFactory;

        } catch (final Exception e) {
            if (e instanceof MappingException) {
                throw (MappingException) e;
            } else {
                throw new MappingException("exception while creating object factory for " + type.getName(), e);
            }
        }
    }

    private static String getPackageName(Type<?> type) {
        Package typePackage = type.getRawType().getPackage();
        return typePackage == null ? "" : typePackage.getName();
    }
    private static String prependPackageName(String packageName, String className) {
        return packageName.isEmpty() || packageName.startsWith("java.") ? className : packageName + "." + className;
    }

    private void addCreateMethod(SourceCodeContext code, UsedTypesContext usedTypes, UsedConvertersContext usedConverters,
            UsedMapperFacadesContext usedMappers, Type<?> type, Type<?> sourceType, MappingContext mappingContext, StringBuilder logDetails) {

        final StringBuilder out = new StringBuilder();
        out.append("public Object create(Object s, " + MappingContext.class.getCanonicalName() + " mappingContext) {");
        out.append(format("if(s == null) throw new %s(\"source object must be not null\");",
                IllegalArgumentException.class.getCanonicalName()));

        out.append(addSourceClassConstructor(code, type, sourceType, mappingContext, logDetails));
        out.append(addUnmatchedSourceHandler(code, type, sourceType, mappingContext, logDetails));

        out.append("\n}");

        code.addMethod(out.toString());
    }

    /**
     * @param code
     * @param destinationType
     * @param sourceType
     * @param mappingContext
     * @param logDetails
     * @return
     */
    private String addSourceClassConstructor(SourceCodeContext code, Type<?> destinationType, Type<?> sourceType,
            MappingContext mappingContext, StringBuilder logDetails) {

        MapperKey mapperKey = new MapperKey(sourceType, destinationType);
        ClassMap<Object, Object> classMap = mapperFactory.getClassMap(mapperKey);

        if (classMap == null) {
            classMap = mapperFactory.getClassMap(new MapperKey(destinationType, sourceType));
        }

        StringBuilder out = new StringBuilder();
        if (classMap != null) {
            if (destinationType.isArray()) {
                out.append(addArrayClassConstructor(code, destinationType, sourceType, classMap.getFieldsMapping().size()));
            } else {

                out.append(format("if (s instanceof %s) {", sourceType.getCanonicalName()));
                out.append(format("%s source = (%s) s;", sourceType.getCanonicalName(), sourceType.getCanonicalName()));
                out.append("\ntry {\n");

                ConstructorMapping<?> constructorMapping = (ConstructorMapping<?>) constructorResolverStrategy.resolve(classMap,
                        destinationType);
                Constructor<?> constructor = constructorMapping.getConstructor();

                if (constructor == null) {
                    throw new IllegalArgumentException("no suitable constructors found for " + destinationType);
                } else if (logDetails != null) {
                    logDetails.append("\n\tUsing constructor: " + constructor);
                }

                List<FieldMap> properties = constructorMapping.getMappedFields();
                Type<?>[] constructorArguments = constructorMapping.getParameterTypes();

                if (constructorArguments == null || properties.size() != constructorArguments.length) {
                    throw new MappingException("While attempting to generate ObjectFactory using constructor '" + constructor
                            + "', an automatic mapping of the source type ('" + sourceType
                            + "') to this constructor call could not be determined. Please "
                            + "register a custom ObjectFactory implementation which is able to create an instance of '" + destinationType
                            + "' from an instance of '" + sourceType + "'.");
                }

                int argIndex = 0;

                argIndex = 0;

                for (FieldMap fieldMap : properties) {
                    VariableRef v = new VariableRef(constructorArguments[argIndex], "arg" + argIndex++);
                    VariableRef s = new VariableRef(fieldMap.getSource(), "source");
                    VariableRef destOwner = new VariableRef(fieldMap.getDestination(), "");
                    v.setOwner(destOwner);
                    out.append(statement(v.declare()));
                    out.append(code.mapFields(fieldMap, s, v));
                }

                out.append(format("return new %s(", destinationType.getCanonicalName()));
                for (int i = 0; i < properties.size(); i++) {
                    out.append(format("arg%d", i));
                    if (i < properties.size() - 1) {
                        out.append(",");
                    }
                }
                out.append(");");
                /*
                 * Any exceptions thrown calling constructors should be
                 * propagated
                 */
                append(out, "\n} catch (java.lang.Exception e) {\n", "if (e instanceof RuntimeException) {\n",
                        "throw (RuntimeException)e;\n", "} else {", "throw new java.lang.RuntimeException("
                                + "\"Error while constructing new " + destinationType.getSimpleName() + " instance\", e);", "\n}\n}\n}");
            }
        }
        return out.toString();
    }

    /**
     * Adds a default constructor call (where possible) as fail-over case when
     * no specific source type has been matched.
     *
     * @param code
     * @param type
     * @param mappingContext
     * @param logDetails
     * @return
     */
    private String addUnmatchedSourceHandler(SourceCodeContext code, Type<?> type, Type<?> sourceType, MappingContext mappingContext,
            StringBuilder logDetails) {
        StringBuilder out = new StringBuilder();
        for (Constructor<?> constructor : type.getRawType().getConstructors()) {
            if (constructor.getParameterTypes().length == 0 && Modifier.isPublic(constructor.getModifiers())) {
                out.append(format("return new %s();", type.getCanonicalName()));
                break;
            }
        }

        /*
         * If no default constructor field exists, attempt to locate and call a
         * constructor which takes a single argument of source type
         */
        if (out.length() == 0) {
            for (Constructor<?> constructor : type.getRawType().getConstructors()) {
                if (constructor.getParameterTypes().length == 1 && Modifier.isPublic(constructor.getModifiers())) {
                    Type<?> argType = TypeFactory.valueOf(constructor.getGenericParameterTypes()[0]);
                    if (argType.isAssignableFrom(sourceType)) {
                        out.append(format("return new %s((%s)s);", type.getCanonicalName(), sourceType.getCanonicalName()));
                        break;
                    }
                }
            }
        }

        if (out.length() == 0) {

            out.append(format(
                    "throw new %s(s.getClass().getCanonicalName() + \" is an unsupported source class for constructing instances of "
                            + type.getCanonicalName() + "\");", IllegalArgumentException.class.getCanonicalName()));
        }

        return out.toString();
    }

    /**
     * @param type
     * @param size
     */
    private String addArrayClassConstructor(SourceCodeContext code, Type<?> type, Type<?> sourceType, int size) {
        return format("if (s instanceof %s) {", sourceType.getCanonicalName()) + "return new "
                + type.getRawType().getComponentType().getCanonicalName() + "[" + size + "];" + "\n}";
    }
}


text:
import { arSA } from 'date-fns/locale'
export = arSA


text:
import React from 'react';
import { Text } from 'react-native';
import { FormattedMessage } from 'react-intl';
import styled from 'styled-components/native';

const StyledText = styled.Text`
    font-size: 10px;
`;

const TabBarLabel = ({ id, tintColor }) => (
    <FormattedMessage id={id}>
        {formattedText => <StyledText style={{ color: tintColor }}>{formattedText}</StyledText>}
    </FormattedMessage>
);

export default TabBarLabel;


text:
BOT_NAME = 'tastykhana'

SPIDER_MODULES = ['tastykhana.spiders']
NEWSPIDER_MODULE = 'tastykhana.spiders'

# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'tastykhana (+http://www.yourdomain.com)'