text:
NSString *const OTRAimImageName               = @"aim.png";
NSString *const OTRGoogleTalkImageName        = @"gtalk.png";
NSString *const OTRXMPPImageName              = @"xmpp.png";
NSString *const OTRXMPPTorImageName           = @"xmpp-tor-logo.png";

@interface OTRAccount ()

//@property (nonatomic) OTRAccountType accountType;

@end

@implementation OTRAccount

@synthesize accountType = _accountType;

- (id)init
{
    if(self = [super init])
    {
        _accountType = OTRAccountTypeNone;
    }
    return self;
}

- (id)initWithAccountType:(OTRAccountType)acctType
{
    if (self = [self init]) {

        _accountType = acctType;
    }
    return self;
}

- (OTRProtocolType)protocolType
{
    return OTRProtocolTypeNone;
}

- (UIImage *)accountImage
{
    return nil;
}

- (NSString *)accountDisplayName
{
    return @"";
}

- (NSString *)protocolTypeString
{
    return @"";
}

- (Class)protocolClass {
    return nil;
}

- (void)setPassword:(NSString *) password {

    if (!password.length || !self.rememberPassword) {
        NSError *error = nil;
        [SSKeychain deletePasswordForService:kOTRServiceName account:self.uniqueId error:&error];
        if (error) {
            DDLogError(@"Error deleting password from keychain: %@%@", [error localizedDescription], [error userInfo]);
        }
        return;
    }
    NSError *error = nil;
    [SSKeychain setPassword:password forService:kOTRServiceName account:self.uniqueId error:&error];
    if (error) {
        DDLogError(@"Error saving password to keychain: %@%@", [error localizedDescription], [error userInfo]);
    }
}

- (NSString *)password {
    if (!self.rememberPassword) {
        return nil;
    }
    NSError *error = nil;
    NSString *password = [SSKeychain passwordForService:kOTRServiceName account:self.uniqueId error:&error];
    if (error) {
        DDLogError(@"Error retreiving password from keychain: %@%@", [error localizedDescription], [error userInfo]);
        error = nil;
    }
    return password;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@ - %@",NSStringFromClass([self class]), self.username];
}

- (NSArray *)allBuddiesWithTransaction:(YapDatabaseReadTransaction *)transaction
{
    NSMutableArray *allBuddies = [NSMutableArray array];
    [[transaction ext:OTRYapDatabaseRelationshipName] enumerateEdgesWithName:OTRBuddyEdges.account destinationKey:self.uniqueId collection:[OTRAccount collection] usingBlock:^(YapDatabaseRelationshipEdge *edge, BOOL *stop) {
        OTRBuddy *buddy = [OTRBuddy fetchObjectWithUniqueID:edge.sourceKey transaction:transaction];
        [allBuddies addObject:buddy];
    }];
    return allBuddies;
}

#pragma mark NSCoding

#pragma - mark Class Methods

+(OTRAccount *)accountForAccountType:(OTRAccountType)accountType
{
    OTRAccount *account = nil;
    if (accountType == OTRAccountTypeJabber) {
        account = [[OTRXMPPAccount alloc] initWithAccountType:accountType];
    }
    else if (accountType == OTRAccountTypeXMPPTor) {
        account = [[OTRXMPPTorAccount alloc] initWithAccountType:accountType];
    }
    else if (accountType == OTRAccountTypeGoogleTalk) {
        account = [[OTRGoogleOAuthXMPPAccount alloc] initWithAccountType:accountType];
    }
    else if (accountType == OTRAccountTypeFacebook) {
        account = [[OTRFacebookOAuthXMPPAccount alloc] initWithAccountType:accountType];
    }

    return account;
}

+ (NSArray *)allAccountsWithUsername:(NSString *)username transaction:(YapDatabaseReadTransaction*)transaction
{
    __block NSMutableArray *accountsArray = [NSMutableArray array];
    [transaction enumerateKeysAndObjectsInCollection:[OTRAccount collection] usingBlock:^(NSString *key, OTRAccount *account, BOOL *stop) {
        if ([account isKindOfClass:[OTRAccount class]] && [account.username isEqualToString:username]) {
            [accountsArray addObject:account];
        }
    }];
    return accountsArray;
}

+ (NSArray *)allAccountsWithTransaction:(YapDatabaseReadTransaction*)transaction
{
    NSMutableArray *accounts = [NSMutableArray array];
    NSArray *allAccountKeys = [transaction allKeysInCollection:[OTRAccount collection]];
    [allAccountKeys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [accounts addObject:[[transaction objectForKey:obj inCollection:[OTRAccount collection]]copy]];
    }];

    return accounts;

}

// See MTLModel+NSCoding.h
// This helps enforce that only the properties keys that we
// desire will be encoded. Be careful to ensure that values
// that should be stored in the keychain don't accidentally
// get serialized!
+ (NSDictionary *)encodingBehaviorsByPropertyKey {
    NSMutableDictionary *behaviors = [NSMutableDictionary dictionaryWithDictionary:[super encodingBehaviorsByPropertyKey]];
    [behaviors setObject:@(MTLModelEncodingBehaviorExcluded) forKey:NSStringFromSelector(@selector(password))];
    return behaviors;
}

@end


text:
layout: post
title:  "Word of Radiance"
date:   2017-11-14
sources: [XGE.171]
tags: [cleric, cantrip, action, evocation]
---

**Evocation cantrip**

**Casting Time**: 1 action

**Range**: 5 feet

**Components**: V, M (a holy symbol)

**Duration**: Instantaneous

You utter a divine word, and burning radiance erupts from you. Each creature of your choice that you can see within range must succeed on a Constitution saving throw or take 1d6 radiant damage.

The spell's damage increases by 1d6 when you reach 5th level (2d6), 11th level (3d6), and 17th level (4d6).

redpajama_set_name: RedPajamaGithub


text:
import os
exec(compile(open(os.path.join(os.path.dirname(__file__),'config')).read(), os.path.join(os.path.dirname(__file__),'config'), 'exec'))

if 'IMGFAC_URL' in os.environ:
  IMGFAC_URL = os.environ['IMGFAC_URL']

# actual utils code
import json
import time
import requests

def build_base(template):
  payload = {'base_image': {'template': template}}
  r = requests.post(IMGFAC_URL+BASE_IMAGE_ENDPOINT, data=json.dumps(payload), headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['base_image']

def get_base(imageid):
  r = requests.get(IMGFAC_URL+BASE_IMAGE_ENDPOINT+'/'+imageid, headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['base_image']

def wait_until_base_completes(imageid):
  currently = 'UNKNOWN'
  while currently not in ['COMPLETE', 'FAILED']:
    time.sleep(POLLING_INTERVAL)
    try:
      imagejson = get_base(imageid)
      currently = imagejson['status']
    except:
      currently = "FAILED"
  return currently

def build_target(template, target_provider):
  payload = {'target_image': {'target': target_provider, 'template': template}}
  r = requests.post(IMGFAC_URL+TARGET_IMAGE_ENDPOINT, data=json.dumps(payload), headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['target_image']

def get_target(imageid):
  r = requests.get(IMGFAC_URL+TARGET_IMAGE_ENDPOINT+'/'+imageid, headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['target_image']

def wait_until_target_completes(imageid):
  currently = 'UNKNOWN'
  while currently not in ['COMPLETE', 'FAILED']:
    time.sleep(POLLING_INTERVAL)
    try:
      imagejson = get_target(imageid)
      currently = imagejson['status']
    except:
      currently = "FAILED"
  return currently

def build_provider(template, provider, provider_definition, provider_credentials):
  payload = {'provider_image': {'target': provider, 'template': template, 'provider': provider_definition, 'credentials': provider_credentials}}
  if provider.lower() == 'ec2':
    payload = {'provider_image': {'target': provider, 'template': template, 'provider': provider_definition, 'credentials': provider_credentials, 'parameters': {'snapshot': True}}}
  r = requests.post(IMGFAC_URL+PROVIDER_IMAGE_ENDPOINT, data=json.dumps(payload), headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['provider_image']

def get_provider(imageid):
  r = requests.get(IMGFAC_URL+PROVIDER_IMAGE_ENDPOINT+'/'+imageid, headers=REQUEST_HEADERS)
  imagejson = json.loads(r.text)
  return imagejson['provider_image']

def wait_until_provider_completes(imageid):
  currently = 'UNKNOWN'
  while currently not in ['COMPLETE', 'FAILED']:
    time.sleep(POLLING_INTERVAL)
    try:
      imagejson = get_provider(imageid)
      currently = imagejson['status']
    except:
      currently = "FAILED"
  return currently

def get_root():
  r = requests.get(IMGFAC_URL, headers=REQUEST_HEADERS)
  return json.loads(r.text)

# code added for target_content.xml testing
import guestfs
import xml.etree.ElementTree as ET

def _compare_mps(a, b):
  if len(a[0]) > len(b[0]):
    return 1
  elif len(a[0]) == len(b[0]):
    return 0
  else:
    return -1

def list_installed_packages(imageid):
  # Gets the imageid imagefile location
  imgfac_config_file = open(IMGFAC_CONF).read()
  imgfac_conf = json.loads(imgfac_config_file)
  storage_path = imgfac_conf['image_manager_args']['storage_path']
  imgfile = imageid + ".body"
  imgfile_path = storage_path + "/" + imgfile
  # Create the guestfs object, attach the disk image and launch the back-end
  g = guestfs.GuestFS()
  g.add_drive(imgfile_path)
  g.launch()
  # Gets the operating systems root
  roots = g.inspect_os()
  # Assumes the first is the one we want to inspect
  root = roots[0]
  # Mount up the disks, like guestfish -i
  # Sort keys by length, shortest first, so that we end up
  # mounting the filesystems in the correct order
  mps = g.inspect_get_mountpoints(root)
  mps.sort(_compare_mps)
  for mp_dev in mps:
    g.mount_ro (mp_dev[1], mp_dev[0])
  apps = g.inspect_list_applications(root)
  # apps is a list of dicts, we extract app_name of every item
  pkgs = [d["app_name"] for d in apps]
  # Unmount everything
  g.umount_all()
  return pkgs

def list_expected_packages(target_provider):
  tree = ET.parse(IMGFAC_TCXML)
  rootel = tree.getroot()
  pkgsel = rootel.findall("./include[@target='" + target_provider + "']/packages/package")
  pkgs = []
  for pkg in pkgsel:
    pkgs.append(pkg.get("name"))
  return pkgs


text:
You can use command `pbcopy` and `pbpast` to interact with the system clipboard in Mac OSX.

```bash
echo 'Hello World' | pbcopy  # Copy from stdin to clipboard
echo `pbpast`  # Copy from clipboard to stdout
```


text:
//=====================================================================
//
//File:      $RCSfile: ModelRecreationResultSuite.java,v $
//Version:   $Revision: 1.8 $
//Modified:  $Date: 2013/01/10 22:44:02 $
//
//(c) Copyright 2007-2014 by Mentor Graphics Corp. All rights reserved.
//
//=====================================================================
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License.  You may obtain a copy
// of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
// License for the specific language governing permissions and limitations under
// the License.
//=====================================================================
import junit.framework.Test;
import junit.framework.TestSuite;

import com.mentor.nucleus.bp.ui.canvas.test.ModelRecreationTests;

public class ModelRecreationResultSuite extends TestSuite {

	public static Test suite() {
        return new ModelRecreationResultSuite();
    }

    /**
     * Construct the test suite.
     */
    public ModelRecreationResultSuite() {
    	ModelRecreationTests.generateResults = true;
    	ModelRecreationTestSuite.initializeRecreationSuite(this);
    }
}


text:
@interface TGLViewController : GLKViewController

@end


text:
04 - ELF Hooking
----------------

The objective of this tutorial is to hook a library function

Scripts and materials are available here: `materials <https://github.com/lief-project/tutorials/tree/master/04_ELF_hooking>`_

By Romain Thomas - `@rh0main <https://twitter.com/rh0main>`_

------

In the previous tutorial we saw how to swap symbols names from a shared library, we will now see the mechanism to hook a function in a shared library.

The targeted library is the standard math library (``libm.so``) and we will insert a hook on the ``exp`` function so that :math:`\exp(x) = x + 1`. The source code of the sample that uses this function is given in the following listing:

.. code-block:: cpp

  #include <stdio.h>
  #include <stdlib.h>
  #include <math.h>

  int main(int argc, char **argv) {
    if (argc != 2) {
      printf("Usage: %s <a> \n", argv[0]);
      exit(-1);
    }

    int a = atoi(argv[1]);
    printf("exp(%d) = %f\n", a, exp(a));
    return 0;
  }

The hooking function is as simple as:

.. code-block:: cpp

  double hook(double x) {
    return x + 1;
  }

Compiled with :code:`gcc -Os -nostdlib -nodefaultlibs -fPIC -Wl,-shared hook.c -o hook`.

To inject this hook into the library, we use the :meth:`~lief.ELF.Binary.add` (segment) method

.. automethod:: lief.ELF.Binary.add
  :noindex:

First, we find the code for our hook function, and add it to the library:

.. code-block:: python

  import lief

  libm = lief.parse("/usr/lib/libm.so.6")
  hook = lief.parse("hook")

  exp_symbol  = libm.get_symbol("exp")
  hook_symbol = hook.get_symbol("hook")

  code_segment = hook.segment_from_virtual_address(hook_symbol.value)
  segment_added = libm.add(code_segment)

Once the stub is injected we just have to calculate the new address for the ``exp`` symbol, and update it:

.. code-block:: python

  new_address = segment_added.virtual_address + hook_symbol.value - code_segment.virtual_address
  exp_symbol.value = new_address

Finally, we write out the patched library to a file in the current folder:

.. code-block:: python

  libm.write("libm.so.6")

To test the patched library:

.. code-block:: console

  $ ./do_math.bin 1
  exp(1) = 2.718282
  $ LD_LIBRARY_PATH=. ./do_math.bin 1
  exp(1) = 2.000000


text:
<?php

namespace backend\models\filter;

use DateTime;

/**
 * Class DateTimeFilter
 * @package backend\models
 */
trait DateTimeFilter
{
    /**
     * Applies date filter to the query.
     * @param $query \yii\db\Query
     * @param $field string
     * @param $date string
     */
    public function applyDateFilter(&$query, $field, $date)
    {
        $parsed = $this->parseDateTime($date);
        if (!is_object($parsed)) return;
        $start = $parsed->setTime(0, 0, 0)->format('Y-m-d H:i:s');
        $end = $parsed->setTime(23, 59, 59)->format('Y-m-d H:i:s');
        $query->andFilterWhere(['between', $field, $start, $end]);
    }

    /**
     * Parses date time from string and returns null if exception is thrown;
     * @param $format
     * @return DateTime|null
     */
    protected function parseDateTime($format)
    {
        if ($format == null) {
            return null;
        }
        try
        {
            return new DateTime($format);
        }
        catch(\Exception $e)
        {
            return null;
        }
    }
}


text:
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */

import React, { PropTypes, Component } from 'react';
import classNames from 'classnames';
import styles from './Navigation.scss';
import withStyles from '../../decorators/withStyles';
import Link from '../Link';

@withStyles(styles)
class Navigation extends Component {

  static propTypes = {
    className: PropTypes.string,
  };

  render() {
    return (

        Video
        About
        Contact
         |
        Log in
        or
        Sign up

    );
  }

}

export default Navigation;


text:
namespace EatVillagers.WolfLab.Logic.Extensions
{
    public static class MathExtensions
    {
        public static int UpperCap(this int value, int cap)
        {
            return value > cap ? cap : value;
        }

        public static int LowerCap(this int value, int cap)
        {
            return value < cap ? cap : value;
        }

        public static decimal UpperCap(this decimal value, decimal cap)
        {
            return value > cap ? cap : value;
        }

        public static decimal LowerCap(this decimal value, decimal cap)
        {
            return value < cap ? cap : value;
        }
    }
}


text:
package com.deploymentio.cfnstacker.template;

import java.util.ArrayList;

public class VelocityObjectList extends ArrayList<Object> {

	private static final long serialVersionUID = -4070134456756521576L;

	public VelocityObjectList() {
		super();
	}
}