Code to remove the files from a particular directory using powershell |
The basic idea is to compare the file's creation date to a specific date
time.
$old = (Get-Date).AddDays(-2)
Get-ChildItem $path -Filter *.log |
Where-Object {!$_.PSIsContainer -and $old -ge $_.CreationTime} |
Remove-Item
|
Remove DIV on mobile devices using jQuery remove |
To do this using screen width:
if ($(window).width() < 797) {
$('#youDiv').remove();
}
Change the 797 to whatever breakpoint you want and add your div id in.
|
Powershell - get serial-number of android devices |
You can try :
$devices=adb devices
$devices | where {$_ -match '(.*)device$'} | % {$Matches[1]}
I select with a regular expession, grouping needed caracters, all the lines
ended with 'device'.
|
Exchange ActiveSync |
(1) There are not many sample/libraries available. Here are your best
bets:
New to Exchange ActiveSync Development? (MSDN blog)
Exchange Server Interoperability Guidance
C# Code sample from MS
Javascript implementation of EAS
If you're looking for Java specifically, buried somewhere in the Android
mail app, which is open source, will be their EAS implementation which also
might be helpful.
(2) Microsoft does not publish licensing costs and anyone who does license
EAS is required to sign an NDA with respect to pricing which is why you
will not see any info regarding pricing anywhere.
|
Removing and then adding back a device in Devices and Printers using PowerShell |
You could probably automate this using MS UI Automation from a Powershell
script.
Here's a hello world UIA Powershell script to get an idea of how to get
started:
[Reflection.Assembly]::LoadFile('C:Program FilesReference
AssembliesMicrosoftFrameworkv3.0UIAutomationClient.dll')
[Reflection.Assembly]::LoadFile('C:Program FilesReference
AssembliesMicrosoftFrameworkv3.0UIAutomationTypes.dll')
# Get the root/desktop element
$rootElement = [Windows.Automation.AutomationElement]::RootElement
# Print its Name and ClassName
Write-Host "Note: In the managed UIA API, the desktop name is empty:"
"'" + $rootElement.Current.Name + "'"
Write-Host "Instead, you can identify the desktop by its ClassName,
#32769:"
"'" + $rootElement.Current.ClassName + "'"
To go beyond that, you might benefit from the
|
xml to wbxml conversion for activesync in iOS |
Use libwbxml. The package has xml2wbxml and wbxml2xml. Code pages are
included.
save this as prov.xml:
<?xml version="1.0"?>
<!DOCTYPE ActiveSync PUBLIC "-//MICROSOFT//DTD ActiveSync//EN"
"http://www.microsoft.com/">
<Provision xmlns="Provision:">
<Policies>
<Policy>
<PolicyType>MS-WAP-Provisioning-XML</PolicyType>
</Policy></Policies></Provision>
then:
xml2wbxml -a prov.xml -o prov.wbxml
You can manipulate wbxml as text.
In https://code.google.com/p/tz-push/
In javascript:
prov.wbxml =
string.fromCharCode(0x03,0x01,0x6A,0x00,0x00,0x0E,0x45,0x46,0x47,0x48,0x03,0x4D,0x53,0x2D,0x57,0x41,0x50,0x2D,0x50,0x72,0x6F,0x76,0x69,0x73,0x69,0x6F,0x6E,0x69,0x6E,0x67,0x2D,0x58,0x4D,0x4C,0x00,0x01,0x01,0x01,0x01)
|
generate activesync profile for lock/wipe via php |
Several notes:
MDM is not ActiceSync
Usually, MDM is standalone protocol/interface with it's own set of
commands. And ActiveSync is another protocol/interface with another set of
commands.
Push down ActiveSync profiles
It's not clear what do you mean. Are you talking about pushing ActiveSync
account configuration (to point device to specific exchange) or are you
talking about sending ActiveSync commands?
Sending ActiveSync commands
You have to implement server side of ActiveSync protocol to send ActiveSync
commands. It could be done several ways:
You use Exchange Server and send commands through it (frankly, I am not
sure what kind of Exchange provides to automate it)
You can use some filter installed before your Exchange Server which will
inject commands on the fly
You can implem
|
Activesync: Sendmail command with MIME Type |
I am sure you have a blank character before the "To" keyword in your code.
Let's remove it. Your data before you encode it to base64 encoding must to
look like this:
From: xxx@xxx.com
To: xxx@xxx.com
Subject: Mail Subject
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
Test body
Best regards,
|
Blacklist or Whitelist applications on iphone using Exchange ActiveSync |
Can you please post a link to Exchange AS documentation. I saw it long-long
time ago and I believe at the moment, it didn't have Blacklist and
Whitelist.
More importantly, Exchange ActiveSync implementations on each platforms are
limited. I haven't heard that Blacklisting was implemeneted on iOS
platform.
Please take my answer with grain of salt, because it's based on quite old
information.
BTW. Super primitive whitelisting can be accomplished by MDM. If device is
supervised, you can install AppLock payload which will lock that device
into one app.
|
Exchange ActiveSync Objective-C Provision Command Bad Request |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URI
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:300.0];
NSString *msgLength = [NSString stringWithFormat:@"%d",[requestBodyData
length]];
NSLog(@"Request Body Data Length: %@",msgLength);
[request setHTTPMethod:@"POST"];
[request setValue:mAuthStringFinal forHTTPHeaderField:@"Authorization"];
[request setValue:@"iPhone" forHTTPHeaderField:@"DeviceType"];
[request setValue:@"application/vnd.ms-sync.wbxml"
forHTTPHeaderField:@"Content-Type"];
[request setValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"12.1" forHTTPHeaderField:@"MS-ASProtocolVersion"];
[request setValue:@"*/*" forHTTPHeaderField:@"Accept"];
[request setValue:@"en
|
Linux - How to remove entries from /proc/devices |
You could do something like this. This works fine. The header file is
ommitted, where all file opeartions are implemented.
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cdev.h>
#include "my_char_device.h"
MODULE_AUTHOR("alakesh");
MODULE_DESCRIPTION("Char Device");
static int r_init(void);
static void r_cleanup(void);
module_init(r_init);
module_exit(r_cleanup);
static struct cdev r_cdev;
static int r_init(void)
{
int ret=0;
dev_t dev;
dev = MKDEV(222,0);
if (register_chrdev_region(dev, 2, "alakesh")){
goto error;
}
cdev_init(&r_cdev, &my_fops);
ret = cdev_add(&r_cdev, dev, 2);
return 0;
error:
unregister_chrdev_region(dev, 2);
return 0;
}
static void r_cleanup(void)
{
cdev_del(&a
|
How Do I Add and Remove Dynamic Audio Devices in Python Gstreamer |
Probably your entire pipeline goes into PAUSE.
Try to follow the steps of the documentation
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-dynamic-pipelines.html
We can't just unlink element2's sinkpad from element1's source pad
because that would leave element1's source pad unlinked and would
cause a streaming error in the pipeline when data is pushed on the
source pad. The technique is to block the dataflow from element1's
source pad before we change element2 by element4 and then resume
dataflow as shown in the following steps:
Block element1's source pad with a blocking pad probe. When the pad
is blocked, the probe callback will be called.
Inside the block callback nothing is flowing between element1 and
element2 and nothing
|
On rapns, how can I know the token for unregistered GCM devices so I can remove them from my database? |
There's no feedback service in Google Cloud Messaging, and there's no need
for one.
When you send a GCM message with a Registration ID of an unregistered
device, you get a response with "NotRegistered" error. That's how you know
the device is unregistered.
I don't know how the rapns API looks like, but assuming it gives you access
to the response from Google, you'll have access to the error code names
returned by Google.
|
Powershell csv remove lines |
If the files are small-ish and you don't care too much about performance,
then the following would be a trivial way:
$data = Import-Csv file1
$vips = Import-Csv file2
$data = $data | ?{ $vips -notcontains $_.Initials }
$data | Export-Csv file1_new -NoTypeInformation
A faster way would be to add the names to remove to a set, but given the
things you're talking about here I doubt you'll get into the range of a few
thousand or million users.
|
Is there a fastclick library (or other solution) in Dart to remove the 300ms delay (ghostclick) on mobile devices? |
The delay is independent of any browser, JavaScript or library like Dart.
It's the way Android detects a double click just by waiting after the first
tap if there will be a second one.
In the lower level API of Android you can react on touch-down and touch-up
events directly. You could implement this using plain java (e.g. as Android
Service), but I've no idea how to call that or listen to its touch-events
using Dart.
|
can't remove permissions on folder with powershell |
All that left is to pipe the current acl (after removal) to the Set-Acl
cmdlet:
$folder_acl | Set-Acl
All True output is the return value of each removed acl. You can suppress
it if you want:
$folder_acl.RemoveAccessRule($_) | Out-Null
|
How do I remove IIS custom header using Powershell? |
To remove the header on iis level:
Remove-WebConfigurationProperty -PSPath MACHINE/WEBROOT/APPHOST
-Filter
system.webServer/httpProtocol/customHeaders
-Name .
-AtElement @{name='X-Powered-By'}
And for a specific site:
Remove-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST/Default
Web Site'
-Filter
system.webServer/httpProtocol/customHeaders
-Name .
-AtElement @{name='X-Powered-By'}
|
Remove a Member from a PowerShell Object? |
I don't think you can remove from an existing object but you can create a
filtered one.
$obj = New-Object -TypeName PsObject -Property @{ Test = 1}
$obj | Add-Member -MemberType NoteProperty -Name Foo -Value Bar
$new_obj = $obj | Select-Object -Property Test
Or
$obj | Select-Object -Property * -ExcludeProperty Foo
This will effectively achieve the same result.
|
Manage devices from code (C#) |
I recently did a project on the Wiimote, faced the exact same problem
you're having.
I found a program named WiimoteConnect:
This little program automatically handles all the install/uninstall
bluetooth connection stuff for you.
|
Powershell: how to remove multiple & directories with exceptions? |
And almost as soon as I posted, the answer came to me -- I had to find only
files, not directories.
Since I'm on PowerShell 2.0, I couldn't use the -File attribute that's new
in powershell 3. Instead, I have to check every object to see if it's a
container.
Solution:
$exclude = @('license.txt', 'settings.txt')
Get-ChildItem C:RootFolder -recurse -exclude $exclude | Where-Object
{!($_.PSIsContainer)} | foreach ($_) {remove-item $_.fullname}
This worked perfectly to achieve what I needed.
Improving on the Solution
Thanks to several comments / posts here, there are some more elegant ways
that taught me a bit more about powershell:
Remove-Item can take commands from a pipe-line. No foreach is necessary.
Where-Object can just be shortened to "?"
Get-ChildItem can be shortened to "gci"
|
Powershell pipeline both remove-item and call function |
Does this work?
Get-ChildItem . -Include bin,obj,Debug,ipch,Resources -Exclude
"*.png","*.bmp","*.jpg","*.htm*","*.xml","*.fl*","*.css" -Recurse | foreach
{ Remove-Item $_.fullname -Force -Recurse; WriteToLog $msg -STATUS
'INFORMATION' }
|
Remove all user accessrights from mailbox in exchange using powershell |
Try this:
Remove-MailboxPermission -Identity MyMailbox -User SomeUser -AccessRights
FullAccess -InheritanceType All
or ( not tested )
$ar = "FullAccess", "SendAs", "ExternalAccount", "DeleteItem",
"ReadPermission", "ChangePermission", "ChangeOwner"
Remove-MailboxPermission -Identity MyMailbox -User SomeUser -AccessRights
$ar -InheritanceType All
|
Commenting out HTML code on mobile devices |
How about this ?
<div class="bg1" id="videos">
<div id="overlay"></div>
</div>
<script type="text/javascript">
var isMobile =
navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/g);
var videos = document.getElementById('videos');
if(!isMobile) {
// User-Agent is not IPhone, IPod, IPad, Android or BlackBerry
videos.innerHTML += '<video autoplay loop class="fillWidth">' +
'<source src="video/videonamehere.mp4" type="video/mp4"/>' +
'<source src="video/videonamehere.ogg" type="video/ogg"/>' +
'<source src="video/videonamehere.webm" type="video/webm"/>' +
'</video>';
} else {
videos.innerHTML += '<img src="/images/fallback.jpg" title="Your
browser does not support the <video> tag"
|
Could the following code produce a crash on older devices? |
Three reasons why this was occurring:
1) The user was on a jail broken phone
2) The version of my app he was installing was an ad hoc release
3) He was trying to access in app purchase
Apparently, jail broken phones are unable to access the sandbox (which is
accessed when you try to do an app purchase on an ad hoc distribution).
|
Powershell 2.0 - Remove Group Membership for List of Disabled Accounts |
It's generally a good idea to also provide a sample of the data you're
operating on (in this case, what the contents of users.csv looks like),
since the key to resolving the problem could lie in the data you're reading
in. However, in this case I believe I can see what's tripping you up
without seeing the data.
Keep in mind that in each stage of the pipeline, $_ is set the the values
of each of the objects from the previous stage of the pipeline. $_.member
doesn't have a consistent value throughout the pipeline.
In the second stage, ForEach-Object {Get-ADPrincipalGroupMembership
-Identity $_.member, $_.member evaluates to the values of the "member"
column of the CSV file. In the third stage, ForEach-Object
{Remove-ADPrincipalGroupMembership -Identity $_.member -MemberOf
SamAccountName},
|
YUV (NV21) to BGR conversion on mobile devices (Native Code) |
Did you try libyuv? I used it in the past and if you compile it with NEON
support, it uses an asm code optimized for ARM processors, you can start
from there to further optimize for your special situation.
|
remove lines which start with *(asterik) in powershell select-string output |
You're escaping the wrong character. You do not want to escape ^ as that's
your anchor for "starting with". You'll want to escape the asterix, so try
this:
$result = Get-Content $file.fullName | Select-String $control |
select-string -pattern "^*" -notmatch
Also, if all you want is the lines, you could also use this:
Get-Content $file.fullName | ? { $_ -match $control -and $_ -notmatch '^*'}
|
Code to force mobile devices to stream mp3 files from website? |
I don't know that much about this sort of stuff. But I would think that
HTML5 would be the best way of going about this.
I have never heard of a website written in PHP or JavaScript that can
stream an MP3 file on a mobile device. I know that a service called
GrooveShark streams on mobile devices using HTML5. Maybe that's worth a
look.
|
Batch / multiple iOS Push Notification code - works for 2 devices, but not for 100 |
You probably have some invalid device tokens in your DB.
In case of an invalid device token, Apple will return an error response if
you use the newer binary format (in which you send a message id and message
expiry), which you don't. In your case an invalid token will simply close
the socket, but you'll have no way to know which message caused the
problem.
You should read about error checking here. You should read about the format
here.
|
How can I code my game to work on every resolution of Android devices? (with Unity) |
The answer to your question largely depends on how you've implemented the
game. If you've created it using GUI textures, then it largely depends on
how you've placed/sized your objects versus screen size, which makes things
a little tricky.
If the majority of your game is done using objects (such as planes, cubes,
etc) then there's two methods I usually choose to use.
1) First method is very easy to implement, though doesn't always look too
good. You can simply change the camera's aspect ratio to match the one
you've designed your game around. So in your case, since you've designed
your game at 4:3, you'd do something like this:
Camera.aspect = 4f/3f;
However, if someone's playing on a screen meant for 16:9, the game will end
up looking distorted and stretched.
2) The second method
|
Is there a way of disabling jquery code when your website is viewed on mobile devices / tablets? |
I use this code to check for a mobiledevice:
if(!
/iphone|ipad|ipod|android|blackberry|mini|windowssce|palm/i.test(navigator.userAgent.toLowerCase()))
{
<THIS CODE WILL NOT BE EXECUTED ON MOBILE DEVICE>
}
U can place that direct into the (document).ready part and include all the
code u dont want on mobile, or u place it around (document).ready if u dont
need any jQuery code at all.
|
remove empty lines from HTML, except in blocks |
Let's assume you have loaded the html as text (HTML):
HTML = """
html
html
html
code-start
code
code
code
code-end
"""
new_html = ""
is_code = False
for line in HTML.split('
'):
# disable empty line remover when code starts
if line == 'code-start':
is_code = True
# check for empty line/is_code
if is_code or line != '':
new_html += line+'
'
# enable empty line remover when code ends
if line == 'code-end':
is_code = False
print new_html
Of course you have to replace code-start and code-end with valid html tags.
This is just a quick and dirty approach but should help you.
|
Howt to connect two devices via bluetooth sending the pairng code by parameter? JAVA-Android |
I think this link will help you find what you need.
I was thinking more of the "Pairing is automatically performed when you
initiate an encrypted connection with the Bluetooth APIs." part of the
link. I haven't tried it but was thinking that pairing automatically means
no user input.
|
Loading Animation Starts On Pre ICS Devices But Will Not Start On Post ICS Devices |
From the developer documentation at
http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
The example shows a call to start() method of the animation.
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start(); // <--------- Does no harm to PRE ICS devices
If you are going to target various droid releases (JB included), why not
call this method?
|
Is there a method, other than enumeration, to get sockets for many IrDA devices when devices all have same deviceID? |
Closing the loop on this old question: The short answer is no, There is
not another method.
IrDA sockets are created and in my case, in Windows 7, enumerated based on
a Windows interrogation of any and all IrDA signals active and in range.
The enumeration process stores data for each unique Device ID
(specifically, IrDA Dev id) it finds. If it sees 3 unique Device IDs, then
data for each can be stored, and made available for a connection to be
completed. Subsequently, for each connection made, separate conversations
can be held with each of those devices. However, if the same three devices
are active, and in range, but have identical Device IDs, Windows will only
store data corresponding to that one ID, and only one connection can be
made.
|
powershell code for comparing two xls files |
If the userIDs in each list in some type of regular order, then it should
be easy to open both workbooks up at the same time, maintain 2 pointers
(Row_for_old_userlist and Row_for_new_userlist) and compare the contents of
the New User ID with the old one.
If they aren't in some semblance of order, then for each item in the new
userlist, you'll have to scan the entire old userlist to find them and then
take your action.
I'm not sure that saving in CSV is a valid approach from your requirements
- you may not be able to get the data that way.
However - I think you're really asking how to set the value of an Excel
spreadsheet cell.
If so, here's some code I use to insert a list of defects into a
spreadsheet...and then set the last cell's column A to a different color.
Strangely enough,
|
get latest code from github with powershell |
You can add a _netrc file in C:UsersBen with your credentials in it:
machine github.com
login yourGitHUbLogin
password yourGitHubPassword
See "Git - How to use .netrc file on windows to save user and password".
If the idea of leaving your credential in plain text doesn't seem a good
one, you can encrypt that file with gpg.
|
How to divide ASCII code in Powershell |
Could you use something like this?
#Set value (I had to set a lower value because your value was way too large
to process with a Int32 (and 64 I think)
$value = 22949672
#Convert (had to multiply because dividing casues to small number to be
save correctly(it rounds up and ruins the decoding later)
Get-Content . est.txt -Encoding Byte | % { $_ * $value } | Set-Content
. est2.txt -Encoding Ascii
#Convert back
Get-Content . est2.txt -Encoding Ascii | % { [byte]($_ / $value) } |
Set-Content . est3.txt -Encoding Byte
|
How to run the powershell code for all system drives? |
You pretty much have it, all you really needed was to get a listing of all
the physical drives on the computer and then loop through it.
A couple other notes:
I removed $results |ft -auto. You probably had it in there as debug output.
You do this twice: $results | sort-object -property size -Descending |
select-object -first 30. I did it once, storing the output back into
$results. Multiple trips of the same data through the same pipeline steps
is inefficient.
I made $a a here-string. Easier to read & work with than concatenating
strings.
I reformatted the date string in your output files so that you can sort
filenames by date.
Don't put files in c:. It's just sloppy. Find a more appropriate location.
This will capture all folders (you aren't filtering them out). Is that
desired?
|
How to run the powershell code against each subfolder that is in the IIS root directory? |
You need to separate folder-traversal (recursive) from file processing
(non-recursive), e.g. like this:
$basedir = 'c:inetpubwwwroot'
$exp = [regex]::Escape($basedir)
$server = 'http://172.16.x.x'
function Create-HtmlList($fldr) {
Get-ChildItem $fldr -Force |
? { -not $_.PSIsContainer } |
select ...
...
} | Set-Content "$fldr.htm"
}
# list files in $basedir:
Create-HtmlList $basedir
# list files in all subfolders of $basedir:
Get-ChildItem $basedir -Recurse -Force |
? { $_.PSIsContainer } |
% {
Create-HtmlList $_.FullName
}
The output files will be put into the respective folder (named after the
folder with the extension .htm appended). If you want a different name or
location for the output files, you need to adjust the Set-Content line in
the function
|