Posts

Showing posts with the label using

Using CURL liberary in php

Using CURL liberary in php The curl liberary in php is very powerfull liberary to get the remote sarver result. Example:s you can get facebook users photo, google map, gmail, and various webservice. Code of curl liberary using basic: Example code to get facebook user photo:   true, // return web page CURLOPT_HEADER => false, // dont return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $url = "http://graph.facebook.com/".$id."/picture"; $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); cur...

Using the Python Requests module to POST documents to Solr

Using the Python Requests module to POST documents to Solr Method Definition The first method accepts the Solr host URL and the JSON payload.  The auto-commit feature is turned off.  The second method will not POST any data, but it will commit any pending transactions. def post (host, data): headers = { "content-type" : "application/json" } params = { "commit" : "false" } return requests . post(host, data = data, params = params, headers = headers) def commit (host): headers = { "content-type" : "application/json" } params = { "commit" : "true" } return requests . post(host, params = params, headers = headers) Method Invocation The most important part of the method invocation is construction of the JSON payload: payload = { "add" : { "doc" : str (data) } } The payload has three aspects: The add  command tells Solr that a Create or Update is going to be perf...

using Ubuntu

using Ubuntu copy files from your local host to a server scp PATHNAME_HERE  target-host:/PATHNAME_THERE scp -rp user1@host1:/filepath1 user2@host2:/filepath2 if you can not get "apt-get" done, that may be because your selected ubuntu mirror server is down. So what you need to do is change the mirror server.  Go to: System->Administration->Update Manager->Settings->Ubuntu Software->Download from, and check the active mirror servers and choose one. search files for some contents in a certain directory find . -type f|xargs grep -e "content" find file-path file-type | xargs grep "content" to see if some application has been installed or not command: $ type <package-name> command: $ apt-cache policy <package-name> setup sharing folder between Ubuntu(guest) and MacOS(host) using VirtualBox step 1: on your host OS, go to VirtualBox -> machine -> settings -> Shared Folders, add the folder, say folder1, you want to share with you...

Using module eval to Define Instance Methods in a Ruby Gem to Enable Per Model Configuration

Using module eval to Define Instance Methods in a Ruby Gem to Enable Per Model Configuration In the last post, I mentioned that I wrote a small gem to post changes to ActiveRecord models to Twitter. In that version, the configuration was handled by a YAML file. I wanted to evolve the gem so that developers could switch Twitter accounts for each model. Basically, I wanted to able to the use the following: class Place { :username => alastrina_gem, :password => QQQQQQ } end After a bit of tinkering and searching, I decided to use the following code in my gem. ALASTRINA_CONFIGURATION_FILE = config/alastrina.yml module Alastrina def self.included(base) base.extend(ClassMethods) end module ClassMethods def alastrina hash module_eval do def configuration throw "Missing #{ALASTRINA_CONFIGURATION_FILE}" unless File.exists? ALASTRINA_CONFIGURATION_FILE @config ||= YAML::load(File.read(ALASTRINA_CONFIGURATION_FILE)) end if hash[:twitter] def send_to_twitter? true end eval...

Using Intellij IDEA 12 for WebLogic Server 12c

Using Intellij IDEA 12 for WebLogic Server 12c If you want to explore the latest EE features, you would need WebLogic Server 12c. However if you still have the IDEA 12 Ultimate edition, you will quickly find that it only supports up to WebLogic Server 11g (10.x)! However you can still make your IDEA 12 U to work with WLS 12c, and all you need is an extra "registry.xml" file under WLS home directory (eg: C:/apps/wls12120/registry.xml). This file will allow the IDEA to pickup and recognize your latest WLS 12c installation. <?xml version="1.0" encoding="UTF-8"?> <bea-product-information>   <host home="C:appswls12120" name="${env.HOST}">     <product format="1.0" name="WebLogic Platform">       <release level="12.0"         ServicePackLevel="6" PatchLevel="0"         Status="installed" BeaProgramGroup="BEA WebLogic Platform 12.0" StartMenu=...

Using SEFAUTIL Server

Image
Using SEFAUTIL Server NOTE : SEFAUTIL Server is being released as BETA. Our main reason for this is to get feedback on PowerShell commandlet format before the community write scripts against the existing commandlets. To give feedback on SEFAUTIL Server please join the Community Yammer forum: Click Here To see the new PowerShell commands that come with SEFAUTIL Server run: get-command �Module SefautilServerPowershell Set-CsUserForwarding Set-CsUserTeamMembers Set-CsUserDelegates Set-CsUserNote Community versus Enterprise Edition   Download SEFAUTIL Server: https://gallery.technet.microsoft.com/lync/SEFAUTIL-Server-Community-6cd286b2 download  file  now

Using multiple worktrees with git

Using multiple worktrees with git Modern development with Git is great. Its really easy to work on a feature branch, make changes, undo changes (oops), and share work with colleagues. However, there are challenges. If Im running tests on my local "beer" branch, I cant easily switch over to the "gin" branch to edit code. The local environment only has one feature branch checked out at a time. I can run tests, or add code, or switch branches, but I cant do two things on two different branches at once... But now I can! Thanks to Manoj Mahalingam S, I know understand the "git worktrees" feature which lets you easily use multiple branches at the same time. Thanks, Manoj! Using multiple worktrees with git download  file  now

Using 7 Zip Hot to sync your archive file with your directory

Image
Using 7 Zip Hot to sync your archive file with your directory 7zG u -t7z -ms=off -uq0 "C:my_document_archive.7z" "C:document" In this case the program 7-zip check in the folder "C:document" the files changed, deleted or new and update the archive "C:my_document_archive.7z" download  file  now

Using a Single Parameter Value to Drive Visibility States of Many Elements in Many Family Instances

Image
Using a Single Parameter Value to Drive Visibility States of Many Elements in Many Family Instances Using some Visibility parameters and a simple formula structure, you can use a Revit family to store a collection elements and then selectively show them by using a single lookup value . This allows you to drive many visibility states (programmatically) through the modification of a single instance parameter value. In the case below, I created a Annotation family and multiple Yes/No visibility parameters, which I applied to Lines: Then, I make a VisibilityEnum integer parameter, and set the Yes/No parameter formulas to a given integer: You can also use Greater Than and other operators to show items that are visible across multiple visibility states: In the project environment, you only need to set one instance parameter to change visibility states: Finally, with some inventive use of Excel and Dynamo, you can drive this visibility parameter programmatically , even mapping the visibili...

Using a Wii U Pro Controller as an Xbox 360 Controller in Windows 10

Image
Using a Wii U Pro Controller as an Xbox 360 Controller in Windows 10 In some VR applications, the Xbox 360 controller is a hardcoded default. If you dont have one, you may be able to emulate with a tool like x360ce. If you specifically have a Wii U Pro Controller, you can connect via Bluetooth and emulate a 360 controller with the steps below. Heres how: Unzip WiinUSoft Install the SCP driver from the subfolder (right click as Administrator)   Go to Bluetooth settings in Windows Pair with Nintendo controller Run WiinUSoft as Administrator Press the X button on the screen to start emulating Xbox 360 controller with Wii U Pro Controller You can also create custom mappings Here is how it shows up under Game Controllers: Some links: WiinUSoft 2.1.zip Download MS_BT_HotFix.zip Download Downloads - WiinUPro download  file  now

Using the Nintendo Wii LAN Adapter on a PC

Using the Nintendo Wii LAN Adapter on a PC Recently My Ethernet LAN Network Card couldnt find the Drivers and wouldnt work; so, Im using my genuine Official Nintendo Wii LAN Adapter as my PCs Ethernet Network card. And Like all PC Hardware under Microsoft Windows, Mac OSX, and even Linux Distributions; They require Hardware Device Drivers. When you Plug an USB Device in to Windows Itll register in the "Windows Device Manager". When Device Manager Runs itll detect the LAN Adapter as "AX88772", It cant find the Driver Software so youll have to download an Installer Manually; Dont worry I already found it on the Manufacturers website, and will add a Link to the Web Site in this Post. And remember these drivers are only for Nintendos LAN Adapter for the Wii; the Wii U LAN Adapter may use different Hardware. And other Vendors like Datel for example will use different Hardware/Drivers. A used Nintendo Wii LAN adapter isnt expensive; Gamestop sells them for around $12 USD....

Using Python to reformat the xml within odt files

Using Python to reformat the xml within odt files A quick python 2,x script to copy, unzip, and uniformly reformat the XML of an .odt file. It adds indentations and line breaks. Useful to debug my invoicing script, which muddles with the xml files, by making the files diff-able and easier to read and easier to search. #!/usr/bin/env python import os import xml.etree.ElementTree as ET odt_path_and_file = path/to/file.odt # This function was copied from http://effbot.org/zone/element-lib.htm def indent(elem, level=0): i = " " + level*" " if len(elem): if not elem.text or not elem.text.strip(): elem.text = i + " " if not elem.tail or not elem.tail.strip(): elem.tail = i for elem in elem: indent(elem, level+1) if not elem.tail or not elem.tail.strip(): elem.tail = i else: if level and (not elem.tail or not elem.tail.strip()): elem.tail = i odt_filename = odt_path_and_file.split(/)[-1] folder_name = (Desktop/ + odt_path_and_file.split(/)[-1].rstrip...

Using Windows Keyboard with OS X

Image
Using Windows Keyboard with OS X � � If you�ve acquired a Macintosh, congratulations and welcome to the club. You�ll want to put your own personal stamp on it and this is an article to show how to use an external Windows keyboard with that Mac. Apple does sell keyboards and many people like to buy them so that everything matches esthetically. Electrically, though, not much distinguishes an Apple keyboard you buy at the Apple Store from a generic Windows keyboard you buy at Frys or Best Buy or even at the 24-hour CVS or Rite-Aid�s office supply aisle. The keyboard use the same USB connectors to plug into the computer and they use the same key codes to tell the operating system that you�ve pressed a particular letter, number or symbol.� One nice feature that I�ve found is that the media control keys lying above the function keys for play/pause, go back a track, go forward a track, increase �volume, decrease volume. work just fine with iTunes 12. �A nice added feature.� Now to the main qu...

Using the Selection Box Tool Anywhere in Revit

Image
Using the Selection Box Tool Anywhere in Revit Selection Box is a new tool in Revit 2016 that allows you to quickly crop a 3D section box around selected elements (without installing any addins). However, it doesnt always show up on the contextual ribbon. For example, if you are editing a family in-place... the tool doesnt seem to be available. However, we can work around this problem by simply adding the Selection Box tool to the Quick Access Toolbar. Select any object When you see the Selection Box tool in the ribbon, right-click on it and Add to Quick Access Toolbar Now, in various other modes in Revit, the tool will still be available :) download  file  now

Vehicular Ad Hoc Networks Simulation Using OMNeT and SUMO step by step from start to end

Image
Vehicular Ad Hoc Networks Simulation Using OMNeT and SUMO step by step from start to end click on images to enlarge   download  file  now

Using Docker to Build Brooklyn

Using Docker to Build Brooklyn Brooklyn is a large project with a lot of dependencies. I wanted to compile it, but I also wanted to remove all traces of the project when I was done experimenting. I used Docker to accomplish this goal. See the files below at https://github.com/medined/docker-brooklyn. First, I created a Dockerfile to load java, maven, and clone the repository. $ cat Dockerfile FROM ubuntu:14.04 MAINTAINER David Medinets # # Install Java # RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:webupd8team/java && echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections && echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections && apt-get update && apt-get install -y oracle-java8-installer ENV JAVA_HOME /usr/lib/jvm/java-8-oracle # # Install Maven # RUN echo "deb http://ppa.launchpad.net/natecarlson/maven3...

using vi text editor as hex editor

Image
using vi text editor as hex editor Pranaam to all bhai ji _/_  Today we will learn how to use vi text editor as hex editor in linux environment .   yes we can use vi text editor as hex editor , which is easy to operate as compare to any hex editor lets start :) open your binary file in vi editor using command vi  file_name i am going to open vlc media player binary file it will be something like this  :D :P some random symbols ok just type :%!xxd and it will switch into hex editing mode dont worry , type  :%!xxd and press enter key you will see something like this >:D< you are in hex editing mode , now edit whatever you want once you have done with editing type  esc key and then type %!xdd -r press enter key, we will back to text editing mode .  now, to save changes type :w changes will be saved  this is how you can use vi editor as hex editor :) Thank you Greetz to :- Zero cool ,code breaker ica, Aasim shaikh,Reborn, Raman kumar rana,INX_r0...

Using Regex to validate E mail and Phone Number

Using Regex to validate E mail and Phone Number Here is the RegEx  expression to validate Phone number and E-mail. RegEx  expression for validating E-mail : /^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/ and the  RegEx  expression for validating Phone number : /^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/ Here is an example of usage of these RegEx  expressions in JavaScript . var emailregex=/^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/; var phoneregex=/^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; if (emailregex.test( string )){ // valid email }else{ // Invalid email } if (phoneregex.test( string )){ // valid phone number }else{ // Invalid phone number } You can replace string with whatever you want. For Example: if (phoneregex.test($(...

test this

test this I run a b" download  file  now

Using SCP with Capistrano

Image
Using SCP with Capistrano It took me several hours to find out how to send a file to my remote computer via scp using Capistrano. Its actually quite easy. There is a method called upload which has a via option. Here is an example of its use: upload("products.txt", "/home/medined", :via => :scp) If you need to change the files name, you can also specify it in the second parameter. For example, upload("products.txt", "/home/medined/products_new.txt", :via => :scp) download  file  now